{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# HiddenLayer Graph Demo - Keras"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Hide GPUs. Not needed for this demo.\n",
    "import os\n",
    "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"\"\n",
    "\n",
    "# Import Keras pre-trained models\n",
    "from tensorflow.keras.applications.vgg16 import VGG16\n",
    "from tensorflow.keras.applications.vgg19 import VGG19\n",
    "from tensorflow.keras.applications.xception import Xception\n",
    "from tensorflow.keras.applications.resnet50 import ResNet50\n",
    "from tensorflow.keras.applications.inception_v3 import InceptionV3\n",
    "from tensorflow.keras.applications.mobilenet import MobileNet\n",
    "from tensorflow.keras.applications.densenet import DenseNet121\n",
    "import tensorflow.keras.backend as K\n",
    "\n",
    "import hiddenlayer as hl\n",
    "import hiddenlayer.transforms as ht"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## VGG 16"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Set the learning phase to training\n",
    "K.set_learning_phase(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: %3 Pages: 1 -->\r\n",
       "<svg width=\"267pt\" height=\"1318pt\"\r\n",
       " viewBox=\"0.00 0.00 266.50 1318.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 1282)\">\r\n",
       "<title>%3</title>\r\n",
       "<polygon fill=\"#ffffff\" stroke=\"none\" points=\"-72,36 -72,-1282 194.5,-1282 194.5,36 -72,36\"/>\r\n",
       "<!-- input_1 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>input_1</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"83,-1246 10,-1246 10,-1210 83,-1210 83,-1246\"/>\r\n",
       "<text text-anchor=\"start\" x=\"18.5\" y=\"-1225\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Placeholder</text>\r\n",
       "</g>\r\n",
       "<!-- 1375821163886916430 -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>1375821163886916430</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"93,-1163 0,-1163 0,-1119 93,-1119 93,-1163\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-1147\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"77.5\" y=\"-1126\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- input_1&#45;&gt;1375821163886916430 -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>input_1&#45;&gt;1375821163886916430</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-1209.8C46.5,-1199.37 46.5,-1185.74 46.5,-1173.44\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-1173.09 46.5,-1163.09 43.0001,-1173.09 50.0001,-1173.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"78.5\" y=\"-1184\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x224x224x3</text>\r\n",
       "</g>\r\n",
       "<!-- block1_pool/MaxPool -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>block1_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"91,-1072 2,-1072 2,-1036 91,-1036 91,-1072\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10.5\" y=\"-1051\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 17007813753289124569 -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>17007813753289124569</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"93,-989 0,-989 0,-945 93,-945 93,-989\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-973\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"77.5\" y=\"-952\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- block1_pool/MaxPool&#45;&gt;17007813753289124569 -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>block1_pool/MaxPool&#45;&gt;17007813753289124569</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-1035.8C46.5,-1025.37 46.5,-1011.74 46.5,-999.443\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-999.09 46.5,-989.09 43.0001,-999.09 50.0001,-999.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"81.5\" y=\"-1010\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x112x112x64</text>\r\n",
       "</g>\r\n",
       "<!-- block2_pool/MaxPool -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>block2_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"91,-898 2,-898 2,-862 91,-862 91,-898\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10.5\" y=\"-877\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 14722730891481860985 -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>14722730891481860985</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"93,-815 0,-815 0,-771 93,-771 93,-815\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-799\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"77.5\" y=\"-778\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">x3</text>\r\n",
       "</g>\r\n",
       "<!-- block2_pool/MaxPool&#45;&gt;14722730891481860985 -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>block2_pool/MaxPool&#45;&gt;14722730891481860985</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-861.799C46.5,-851.369 46.5,-837.742 46.5,-825.443\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-825.09 46.5,-815.09 43.0001,-825.09 50.0001,-825.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"78.5\" y=\"-836\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x56x56x128</text>\r\n",
       "</g>\r\n",
       "<!-- block3_pool/MaxPool -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>block3_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"91,-724 2,-724 2,-688 91,-688 91,-724\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10.5\" y=\"-703\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 15167735196483041546 -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>15167735196483041546</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"93,-641 0,-641 0,-597 93,-597 93,-641\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-625\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"77.5\" y=\"-604\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">x3</text>\r\n",
       "</g>\r\n",
       "<!-- block3_pool/MaxPool&#45;&gt;15167735196483041546 -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>block3_pool/MaxPool&#45;&gt;15167735196483041546</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-687.799C46.5,-677.369 46.5,-663.742 46.5,-651.443\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-651.09 46.5,-641.09 43.0001,-651.09 50.0001,-651.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"78.5\" y=\"-662\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x28x28x256</text>\r\n",
       "</g>\r\n",
       "<!-- block4_pool/MaxPool -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>block4_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"91,-550 2,-550 2,-514 91,-514 91,-550\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10.5\" y=\"-529\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 3290371169422309658 -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>3290371169422309658</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"93,-467 0,-467 0,-423 93,-423 93,-467\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-451\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"77.5\" y=\"-430\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">x3</text>\r\n",
       "</g>\r\n",
       "<!-- block4_pool/MaxPool&#45;&gt;3290371169422309658 -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>block4_pool/MaxPool&#45;&gt;3290371169422309658</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-513.799C46.5,-503.369 46.5,-489.742 46.5,-477.443\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-477.09 46.5,-467.09 43.0001,-477.09 50.0001,-477.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"78.5\" y=\"-488\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- block5_pool/MaxPool -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>block5_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"91,-376 2,-376 2,-340 91,-340 91,-376\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10.5\" y=\"-355\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- flatten/Reshape -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>flatten/Reshape</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"75.5,-293 17.5,-293 17.5,-257 75.5,-257 75.5,-293\"/>\r\n",
       "<text text-anchor=\"start\" x=\"25.5\" y=\"-272\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Reshape</text>\r\n",
       "</g>\r\n",
       "<!-- block5_pool/MaxPool&#45;&gt;flatten/Reshape -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>block5_pool/MaxPool&#45;&gt;flatten/Reshape</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-339.822C46.5,-329.19 46.5,-315.306 46.5,-303.204\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-303.153 46.5,-293.153 43.0001,-303.153 50.0001,-303.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"72.5\" y=\"-314\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x7x7x512</text>\r\n",
       "</g>\r\n",
       "<!-- 11350230189420503396 -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>11350230189420503396</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"86.5,-210 6.5,-210 6.5,-166 86.5,-166 86.5,-210\"/>\r\n",
       "<text text-anchor=\"start\" x=\"14.5\" y=\"-194\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Linear &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"70.5\" y=\"-173\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- flatten/Reshape&#45;&gt;11350230189420503396 -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>flatten/Reshape&#45;&gt;11350230189420503396</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-256.799C46.5,-246.369 46.5,-232.742 46.5,-220.443\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-220.09 46.5,-210.09 43.0001,-220.09 50.0001,-220.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"67\" y=\"-231\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x25088</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/MatMul -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>predictions/MatMul</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"73.5,-119 19.5,-119 19.5,-83 73.5,-83 73.5,-119\"/>\r\n",
       "<text text-anchor=\"start\" x=\"31.5\" y=\"-98\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Linear</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/Softmax -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>predictions/Softmax</title>\r\n",
       "<polygon fill=\"#bcd6fc\" stroke=\"#7c96bc\" points=\"75,-36 18,-36 18,-0 75,-0 75,-36\"/>\r\n",
       "<text text-anchor=\"start\" x=\"26.5\" y=\"-15\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">Softmax</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/MatMul&#45;&gt;predictions/Softmax -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>predictions/MatMul&#45;&gt;predictions/Softmax</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-82.822C46.5,-72.1903 46.5,-58.306 46.5,-46.2035\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-46.1532 46.5,-36.1533 43.0001,-46.1533 50.0001,-46.1532\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"64\" y=\"-57\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x1000</text>\r\n",
       "</g>\r\n",
       "<!-- 1375821163886916430&#45;&gt;block1_pool/MaxPool -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>1375821163886916430&#45;&gt;block1_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-1118.99C46.5,-1107.92 46.5,-1094.22 46.5,-1082.34\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-1082.06 46.5,-1072.06 43.0001,-1082.06 50.0001,-1082.06\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"81.5\" y=\"-1093\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x224x224x64</text>\r\n",
       "</g>\r\n",
       "<!-- 17007813753289124569&#45;&gt;block2_pool/MaxPool -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>17007813753289124569&#45;&gt;block2_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-944.989C46.5,-933.923 46.5,-920.219 46.5,-908.336\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-908.062 46.5,-898.062 43.0001,-908.062 50.0001,-908.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"84.5\" y=\"-919\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x112x112x128</text>\r\n",
       "</g>\r\n",
       "<!-- 11350230189420503396&#45;&gt;predictions/MatMul -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>11350230189420503396&#45;&gt;predictions/MatMul</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-165.989C46.5,-154.923 46.5,-141.219 46.5,-129.336\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-129.062 46.5,-119.062 43.0001,-129.062 50.0001,-129.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"64\" y=\"-140\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x4096</text>\r\n",
       "</g>\r\n",
       "<!-- 14722730891481860985&#45;&gt;block3_pool/MaxPool -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>14722730891481860985&#45;&gt;block3_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-770.989C46.5,-759.923 46.5,-746.219 46.5,-734.336\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-734.062 46.5,-724.062 43.0001,-734.062 50.0001,-734.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"78.5\" y=\"-745\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x56x56x256</text>\r\n",
       "</g>\r\n",
       "<!-- 15167735196483041546&#45;&gt;block4_pool/MaxPool -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>15167735196483041546&#45;&gt;block4_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-596.989C46.5,-585.923 46.5,-572.219 46.5,-560.336\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-560.062 46.5,-550.062 43.0001,-560.062 50.0001,-560.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"78.5\" y=\"-571\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x28x28x512</text>\r\n",
       "</g>\r\n",
       "<!-- 3290371169422309658&#45;&gt;block5_pool/MaxPool -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>3290371169422309658&#45;&gt;block5_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#7c96bc\" d=\"M46.5,-422.989C46.5,-411.923 46.5,-398.219 46.5,-386.336\"/>\r\n",
       "<polygon fill=\"#7c96bc\" stroke=\"#7c96bc\" points=\"50.0001,-386.062 46.5,-376.062 43.0001,-386.062 50.0001,-386.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"78.5\" y=\"-397\" font-family=\"Verdana\" font-size=\"10.00\" fill=\"#202020\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<hiddenlayer.graph.Graph at 0x17417d11208>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Build the model\n",
    "model = VGG16(input_shape=(224, 224, 3))\n",
    "\n",
    "# Build model graph view\n",
    "hl_graph = hl.build_graph(K.get_session().graph)\n",
    "\n",
    "# Display graph view\n",
    "hl_graph.theme = hl.graph.THEMES[\"blue\"].copy()\n",
    "hl_graph"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "heading_collapsed": true
   },
   "source": [
    "## Transforms and Graph Expressions\n",
    "\n",
    "A Graph Expression is like a Regular Expression for graphs. It simplifies searching for nodes that fit a particular pattern. For example, the graph expression `Conv > Relu` will find Conv layers that are followed by RELU layers. And the expressions `Conv | MaxPool` will match any Conv and MaxPool layers that are in parallel branches (i.e. have the same parent node). See examples of more complex graph expressions below.\n",
    "\n",
    "Once the graph expression finds the nodes, we use Transforms to modify them. For example, if we want to delete all nodes of type `Const`, we'll use the transform `Prune(\"Const\")`. The graph expression here is simple, `Const`, which matches any node with operation of type Const. And the Prune() transform deletes the node.\n",
    "\n",
    "See more examples below. And, also, check `SIMPLICITY_TRANSFORMS` in `transforms.py`."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## VGG19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a new graph and set the learning phase to inference\n",
    "K.clear_session()\n",
    "K.set_learning_phase(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: %3 Pages: 1 -->\r\n",
       "<svg width=\"252pt\" height=\"1318pt\"\r\n",
       " viewBox=\"0.00 0.00 252.00 1318.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 1282)\">\r\n",
       "<title>%3</title>\r\n",
       "<polygon fill=\"#ffffff\" stroke=\"none\" points=\"-72,36 -72,-1282 180,-1282 180,36 -72,36\"/>\r\n",
       "<!-- input_1 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>input_1</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"75,-1246 9,-1246 9,-1210 75,-1210 75,-1246\"/>\r\n",
       "<text text-anchor=\"start\" x=\"17\" y=\"-1225\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Placeholder</text>\r\n",
       "</g>\r\n",
       "<!-- 10226194862442200930 -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>10226194862442200930</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"84,-1163 0,-1163 0,-1119 84,-1119 84,-1163\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8\" y=\"-1147\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"70\" y=\"-1126\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- input_1&#45;&gt;10226194862442200930 -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>input_1&#45;&gt;10226194862442200930</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-1209.8C42,-1199.37 42,-1185.74 42,-1173.44\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-1173.09 42,-1163.09 38.5001,-1173.09 45.5001,-1173.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"69.5\" y=\"-1184\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x224x224x3</text>\r\n",
       "</g>\r\n",
       "<!-- block1_pool/MaxPool -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>block1_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"82,-1072 2,-1072 2,-1036 82,-1036 82,-1072\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10\" y=\"-1051\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 17053019381008504496 -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>17053019381008504496</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"84,-989 0,-989 0,-945 84,-945 84,-989\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8\" y=\"-973\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"70\" y=\"-952\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- block1_pool/MaxPool&#45;&gt;17053019381008504496 -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>block1_pool/MaxPool&#45;&gt;17053019381008504496</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-1035.8C42,-1025.37 42,-1011.74 42,-999.443\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-999.09 42,-989.09 38.5001,-999.09 45.5001,-999.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"72.5\" y=\"-1010\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x112x112x64</text>\r\n",
       "</g>\r\n",
       "<!-- block2_pool/MaxPool -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>block2_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"82,-898 2,-898 2,-862 82,-862 82,-898\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10\" y=\"-877\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 11981966316608548327 -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>11981966316608548327</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"84,-815 0,-815 0,-771 84,-771 84,-815\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8\" y=\"-799\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"70\" y=\"-778\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">x4</text>\r\n",
       "</g>\r\n",
       "<!-- block2_pool/MaxPool&#45;&gt;11981966316608548327 -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>block2_pool/MaxPool&#45;&gt;11981966316608548327</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-861.799C42,-851.369 42,-837.742 42,-825.443\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-825.09 42,-815.09 38.5001,-825.09 45.5001,-825.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"69.5\" y=\"-836\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x56x56x128</text>\r\n",
       "</g>\r\n",
       "<!-- block3_pool/MaxPool -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>block3_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"82,-724 2,-724 2,-688 82,-688 82,-724\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10\" y=\"-703\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 18422773042293609649 -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>18422773042293609649</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"84,-641 0,-641 0,-597 84,-597 84,-641\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8\" y=\"-625\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"70\" y=\"-604\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">x4</text>\r\n",
       "</g>\r\n",
       "<!-- block3_pool/MaxPool&#45;&gt;18422773042293609649 -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>block3_pool/MaxPool&#45;&gt;18422773042293609649</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-687.799C42,-677.369 42,-663.742 42,-651.443\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-651.09 42,-641.09 38.5001,-651.09 45.5001,-651.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"69.5\" y=\"-662\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x28x28x256</text>\r\n",
       "</g>\r\n",
       "<!-- block4_pool/MaxPool -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>block4_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"82,-550 2,-550 2,-514 82,-514 82,-550\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10\" y=\"-529\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 10484853735615617762 -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>10484853735615617762</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"84,-467 0,-467 0,-423 84,-423 84,-467\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8\" y=\"-451\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Conv3x3 &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"70\" y=\"-430\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">x4</text>\r\n",
       "</g>\r\n",
       "<!-- block4_pool/MaxPool&#45;&gt;10484853735615617762 -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>block4_pool/MaxPool&#45;&gt;10484853735615617762</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-513.799C42,-503.369 42,-489.742 42,-477.443\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-477.09 42,-467.09 38.5001,-477.09 45.5001,-477.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"69.5\" y=\"-488\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- block5_pool/MaxPool -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>block5_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"82,-376 2,-376 2,-340 82,-340 82,-376\"/>\r\n",
       "<text text-anchor=\"start\" x=\"10\" y=\"-355\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">MaxPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- flatten/Reshape -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>flatten/Reshape</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"69,-293 15,-293 15,-257 69,-257 69,-293\"/>\r\n",
       "<text text-anchor=\"start\" x=\"24\" y=\"-272\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Reshape</text>\r\n",
       "</g>\r\n",
       "<!-- block5_pool/MaxPool&#45;&gt;flatten/Reshape -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>block5_pool/MaxPool&#45;&gt;flatten/Reshape</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-339.822C42,-329.19 42,-315.306 42,-303.204\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-303.153 42,-293.153 38.5001,-303.153 45.5001,-303.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"64.5\" y=\"-314\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x7x7x512</text>\r\n",
       "</g>\r\n",
       "<!-- 2800143362118675971 -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>2800143362118675971</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"69,-210 15,-210 15,-166 69,-166 69,-210\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36\" y=\"-194\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">FC</text>\r\n",
       "<text text-anchor=\"start\" x=\"42\" y=\"-173\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- flatten/Reshape&#45;&gt;2800143362118675971 -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>flatten/Reshape&#45;&gt;2800143362118675971</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-256.799C42,-246.369 42,-232.742 42,-220.443\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-220.09 42,-210.09 38.5001,-220.09 45.5001,-220.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"60\" y=\"-231\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x25088</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/MatMul -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>predictions/MatMul</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"69,-119 15,-119 15,-83 69,-83 69,-119\"/>\r\n",
       "<text text-anchor=\"start\" x=\"29\" y=\"-98\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Linear</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/Softmax -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>predictions/Softmax</title>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"69,-36 15,-36 15,-0 69,-0 69,-36\"/>\r\n",
       "<text text-anchor=\"start\" x=\"24\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">Softmax</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/MatMul&#45;&gt;predictions/Softmax -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>predictions/MatMul&#45;&gt;predictions/Softmax</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-82.822C42,-72.1903 42,-58.306 42,-46.2035\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-46.1532 42,-36.1533 38.5001,-46.1533 45.5001,-46.1532\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"57.5\" y=\"-57\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x1000</text>\r\n",
       "</g>\r\n",
       "<!-- 10226194862442200930&#45;&gt;block1_pool/MaxPool -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>10226194862442200930&#45;&gt;block1_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-1118.99C42,-1107.92 42,-1094.22 42,-1082.34\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-1082.06 42,-1072.06 38.5001,-1082.06 45.5001,-1082.06\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"72.5\" y=\"-1093\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x224x224x64</text>\r\n",
       "</g>\r\n",
       "<!-- 17053019381008504496&#45;&gt;block2_pool/MaxPool -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>17053019381008504496&#45;&gt;block2_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-944.989C42,-933.923 42,-920.219 42,-908.336\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-908.062 42,-898.062 38.5001,-908.062 45.5001,-908.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"75\" y=\"-919\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x112x112x128</text>\r\n",
       "</g>\r\n",
       "<!-- 2800143362118675971&#45;&gt;predictions/MatMul -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>2800143362118675971&#45;&gt;predictions/MatMul</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-165.989C42,-154.923 42,-141.219 42,-129.336\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-129.062 42,-119.062 38.5001,-129.062 45.5001,-129.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"57.5\" y=\"-140\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x4096</text>\r\n",
       "</g>\r\n",
       "<!-- 11981966316608548327&#45;&gt;block3_pool/MaxPool -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>11981966316608548327&#45;&gt;block3_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-770.989C42,-759.923 42,-746.219 42,-734.336\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-734.062 42,-724.062 38.5001,-734.062 45.5001,-734.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"69.5\" y=\"-745\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x56x56x256</text>\r\n",
       "</g>\r\n",
       "<!-- 18422773042293609649&#45;&gt;block4_pool/MaxPool -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>18422773042293609649&#45;&gt;block4_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-596.989C42,-585.923 42,-572.219 42,-560.336\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-560.062 42,-550.062 38.5001,-560.062 45.5001,-560.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"69.5\" y=\"-571\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x28x28x512</text>\r\n",
       "</g>\r\n",
       "<!-- 10484853735615617762&#45;&gt;block5_pool/MaxPool -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>10484853735615617762&#45;&gt;block5_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#789263\" d=\"M42,-422.989C42,-411.923 42,-398.219 42,-386.336\"/>\r\n",
       "<polygon fill=\"#789263\" stroke=\"#789263\" points=\"45.5001,-386.062 42,-376.062 38.5001,-386.062 45.5001,-386.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"69.5\" y=\"-397\" font-family=\"Times\" font-size=\"10.00\" fill=\"#ffffff\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<hiddenlayer.graph.Graph at 0x17418071780>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Build the model\n",
    "model = VGG19(input_shape=(224, 224, 3))\n",
    "\n",
    "# Define custom transforms to group nodes differently\n",
    "transforms = [\n",
    "    # Build basic folds first\n",
    "    ht.Fold(\"Conv > Relu\", \"ConvRelu\"),\n",
    "    # Display fully-connected layers differently\n",
    "    ht.Fold(\"Linear > Relu\", \"FC\", \"FC\"),\n",
    "    # Fold repeated nodes\n",
    "    ht.FoldDuplicates(),\n",
    "]\n",
    "\n",
    "# Build model graph view\n",
    "hl_graph = hl.build_graph(K.get_session().graph, transforms=transforms)\n",
    "\n",
    "# Customize the theme. The theme is a simple dict defined in graph.py\n",
    "hl_graph.theme.update({\n",
    "    \"fill_color\": \"#789263\",\n",
    "    \"outline_color\": \"#789263\",\n",
    "    \"font_color\": \"#FFFFFF\",\n",
    "})\n",
    "\n",
    "# Display graph view\n",
    "hl_graph"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Xception with Xception module"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a new graph and set the learning phase to inference\n",
    "K.clear_session()\n",
    "K.set_learning_phase(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Build the model\n",
    "model = Xception(input_shape=(399, 399, 3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: %3 Pages: 1 -->\r\n",
       "<svg width=\"497pt\" height=\"2232pt\"\r\n",
       " viewBox=\"0.00 0.00 496.50 2232.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 2196)\">\r\n",
       "<title>%3</title>\r\n",
       "<polygon fill=\"#ffffff\" stroke=\"none\" points=\"-72,36 -72,-2196 424.5,-2196 424.5,36 -72,36\"/>\r\n",
       "<!-- input_1 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>input_1</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"152.5,-2160 86.5,-2160 86.5,-2124 152.5,-2124 152.5,-2160\"/>\r\n",
       "<text text-anchor=\"start\" x=\"94.5\" y=\"-2139\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Placeholder</text>\r\n",
       "</g>\r\n",
       "<!-- 8613720893937014618 -->\r\n",
       "<g id=\"node16\" class=\"node\"><title>8613720893937014618</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"182,-2077 57,-2077 57,-2041 182,-2041 182,-2077\"/>\r\n",
       "<text text-anchor=\"start\" x=\"65.5\" y=\"-2056\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv3x3/s2 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- input_1&#45;&gt;8613720893937014618 -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>input_1&#45;&gt;8613720893937014618</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M119.5,-2123.82C119.5,-2113.19 119.5,-2099.31 119.5,-2087.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"123,-2087.15 119.5,-2077.15 116,-2087.15 123,-2087.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"147\" y=\"-2098\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x399x399x3</text>\r\n",
       "</g>\r\n",
       "<!-- block1_conv1_act/Relu -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>block1_conv1_act/Relu</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"146.5,-1994 92.5,-1994 92.5,-1958 146.5,-1958 146.5,-1994\"/>\r\n",
       "<text text-anchor=\"start\" x=\"110.5\" y=\"-1973\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu</text>\r\n",
       "</g>\r\n",
       "<!-- 3905769776342706844 -->\r\n",
       "<g id=\"node17\" class=\"node\"><title>3905769776342706844</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"175.5,-1911 63.5,-1911 63.5,-1875 175.5,-1875 175.5,-1911\"/>\r\n",
       "<text text-anchor=\"start\" x=\"71.5\" y=\"-1890\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv3x3 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- block1_conv1_act/Relu&#45;&gt;3905769776342706844 -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>block1_conv1_act/Relu&#45;&gt;3905769776342706844</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M119.5,-1957.82C119.5,-1947.19 119.5,-1933.31 119.5,-1921.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"123,-1921.15 119.5,-1911.15 116,-1921.15 123,-1921.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"150\" y=\"-1932\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x199x199x32</text>\r\n",
       "</g>\r\n",
       "<!-- block1_conv2_act/Relu -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>block1_conv2_act/Relu</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"146.5,-1828 92.5,-1828 92.5,-1792 146.5,-1792 146.5,-1828\"/>\r\n",
       "<text text-anchor=\"start\" x=\"110.5\" y=\"-1807\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu</text>\r\n",
       "</g>\r\n",
       "<!-- 16674503091031775128 -->\r\n",
       "<g id=\"node18\" class=\"node\"><title>16674503091031775128</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"125,-1691 0,-1691 0,-1655 125,-1655 125,-1691\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-1670\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1/s2 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- block1_conv2_act/Relu&#45;&gt;16674503091031775128 -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>block1_conv2_act/Relu&#45;&gt;16674503091031775128</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.144,-1791.69C99.9278,-1786.29 95.6543,-1780.14 92.5,-1774 80.5873,-1750.79 72.5875,-1722.08 67.866,-1701.38\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"71.2326,-1700.39 65.6924,-1691.36 64.3917,-1701.87 71.2326,-1700.39\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"123\" y=\"-1766\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x197x197x64</text>\r\n",
       "</g>\r\n",
       "<!-- 2855760635569220863 -->\r\n",
       "<g id=\"node22\" class=\"node\"><title>2855760635569220863</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"306.5,-1745 102.5,-1745 102.5,-1709 306.5,-1709 306.5,-1745\"/>\r\n",
       "<text text-anchor=\"start\" x=\"110.5\" y=\"-1724\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; Conv1x1 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- block1_conv2_act/Relu&#45;&gt;2855760635569220863 -->\r\n",
       "<g id=\"edge19\" class=\"edge\"><title>block1_conv2_act/Relu&#45;&gt;2855760635569220863</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M137.526,-1791.82C149.585,-1780.33 165.63,-1765.04 178.992,-1752.31\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"181.675,-1754.59 186.5,-1745.15 176.846,-1749.52 181.675,-1754.59\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"198\" y=\"-1766\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x197x197x64</text>\r\n",
       "</g>\r\n",
       "<!-- block2_pool/MaxPool -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>block2_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"191.5,-1554 111.5,-1554 111.5,-1518 191.5,-1518 191.5,-1554\"/>\r\n",
       "<text text-anchor=\"start\" x=\"119.5\" y=\"-1533\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- add/add -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>add/add</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"118.5,-1471 64.5,-1471 64.5,-1435 118.5,-1435 118.5,-1471\"/>\r\n",
       "<text text-anchor=\"start\" x=\"83.5\" y=\"-1450\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Add</text>\r\n",
       "</g>\r\n",
       "<!-- block2_pool/MaxPool&#45;&gt;add/add -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>block2_pool/MaxPool&#45;&gt;add/add</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M138.776,-1517.82C130.503,-1506.65 119.571,-1491.9 110.303,-1479.38\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"112.971,-1477.11 104.206,-1471.15 107.346,-1481.27 112.971,-1477.11\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"153\" y=\"-1492\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x99x99x128</text>\r\n",
       "</g>\r\n",
       "<!-- 8666875710014757387 -->\r\n",
       "<g id=\"node19\" class=\"node\"><title>8666875710014757387</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131,-1326 6,-1326 6,-1290 131,-1290 131,-1326\"/>\r\n",
       "<text text-anchor=\"start\" x=\"14.5\" y=\"-1305\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1/s2 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- add/add&#45;&gt;8666875710014757387 -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>add/add&#45;&gt;8666875710014757387</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M86.1166,-1434.91C84.3254,-1429.22 82.3229,-1422.84 80.5,-1417 76.4769,-1404.12 73.7757,-1401.3 71.5,-1388 68.5946,-1371.02 67.8172,-1351.69 67.7795,-1336.41\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"71.2819,-1336.11 67.8629,-1326.08 64.2821,-1336.06 71.2819,-1336.11\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"108\" y=\"-1409\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x99x99x128</text>\r\n",
       "</g>\r\n",
       "<!-- 4833487269871428874 -->\r\n",
       "<g id=\"node26\" class=\"node\"><title>4833487269871428874</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"316.5,-1388 80.5,-1388 80.5,-1344 316.5,-1344 316.5,-1388\"/>\r\n",
       "<text text-anchor=\"start\" x=\"88.5\" y=\"-1372\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu &gt; SeparableConv3x3 &gt; Conv1x1 &gt; BatchNorm</text>\r\n",
       "<text text-anchor=\"start\" x=\"302.5\" y=\"-1351\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- add/add&#45;&gt;4833487269871428874 -->\r\n",
       "<g id=\"edge25\" class=\"edge\"><title>add/add&#45;&gt;4833487269871428874</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M113.153,-1434.8C127.742,-1423.21 147.299,-1407.67 164.011,-1394.4\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"166.299,-1397.05 171.952,-1388.09 161.945,-1391.57 166.299,-1397.05\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"176\" y=\"-1409\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x99x99x128</text>\r\n",
       "</g>\r\n",
       "<!-- block3_pool/MaxPool -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>block3_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"227.5,-1272 147.5,-1272 147.5,-1236 227.5,-1236 227.5,-1272\"/>\r\n",
       "<text text-anchor=\"start\" x=\"155.5\" y=\"-1251\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- add_1/add -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>add_1/add</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"136.5,-1189 82.5,-1189 82.5,-1153 136.5,-1153 136.5,-1189\"/>\r\n",
       "<text text-anchor=\"start\" x=\"101.5\" y=\"-1168\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Add</text>\r\n",
       "</g>\r\n",
       "<!-- block3_pool/MaxPool&#45;&gt;add_1/add -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>block3_pool/MaxPool&#45;&gt;add_1/add</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M170.958,-1235.82C159.996,-1224.44 145.444,-1209.33 133.251,-1196.66\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"135.476,-1193.93 126.018,-1189.15 130.433,-1198.78 135.476,-1193.93\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"181\" y=\"-1210\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x50x50x256</text>\r\n",
       "</g>\r\n",
       "<!-- 16814389691786605164 -->\r\n",
       "<g id=\"node20\" class=\"node\"><title>16814389691786605164</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"149,-1044 24,-1044 24,-1008 149,-1008 149,-1044\"/>\r\n",
       "<text text-anchor=\"start\" x=\"32.5\" y=\"-1023\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1/s2 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- add_1/add&#45;&gt;16814389691786605164 -->\r\n",
       "<g id=\"edge16\" class=\"edge\"><title>add_1/add&#45;&gt;16814389691786605164</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.117,-1152.91C102.325,-1147.22 100.323,-1140.84 98.5,-1135 94.4769,-1122.12 91.7757,-1119.3 89.5,-1106 86.5946,-1089.02 85.8172,-1069.69 85.7795,-1054.41\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"89.2819,-1054.11 85.8629,-1044.08 82.2821,-1054.06 89.2819,-1054.11\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"126\" y=\"-1127\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x50x50x256</text>\r\n",
       "</g>\r\n",
       "<!-- 13388773562632226509 -->\r\n",
       "<g id=\"node27\" class=\"node\"><title>13388773562632226509</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"334.5,-1106 98.5,-1106 98.5,-1062 334.5,-1062 334.5,-1106\"/>\r\n",
       "<text text-anchor=\"start\" x=\"106.5\" y=\"-1090\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu &gt; SeparableConv3x3 &gt; Conv1x1 &gt; BatchNorm</text>\r\n",
       "<text text-anchor=\"start\" x=\"320.5\" y=\"-1069\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- add_1/add&#45;&gt;13388773562632226509 -->\r\n",
       "<g id=\"edge27\" class=\"edge\"><title>add_1/add&#45;&gt;13388773562632226509</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M131.153,-1152.8C145.742,-1141.21 165.299,-1125.67 182.011,-1112.4\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"184.299,-1115.05 189.952,-1106.09 179.945,-1109.57 184.299,-1115.05\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"194\" y=\"-1127\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x50x50x256</text>\r\n",
       "</g>\r\n",
       "<!-- block4_pool/MaxPool -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>block4_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"245.5,-990 165.5,-990 165.5,-954 245.5,-954 245.5,-990\"/>\r\n",
       "<text text-anchor=\"start\" x=\"173.5\" y=\"-969\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- add_2/add -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>add_2/add</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"154.5,-907 100.5,-907 100.5,-871 154.5,-871 154.5,-907\"/>\r\n",
       "<text text-anchor=\"start\" x=\"119.5\" y=\"-886\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Add</text>\r\n",
       "</g>\r\n",
       "<!-- block4_pool/MaxPool&#45;&gt;add_2/add -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>block4_pool/MaxPool&#45;&gt;add_2/add</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M188.958,-953.822C177.996,-942.439 163.444,-927.326 151.251,-914.665\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"153.476,-911.929 144.018,-907.153 148.433,-916.784 153.476,-911.929\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"199\" y=\"-928\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x25x25x728</text>\r\n",
       "</g>\r\n",
       "<!-- 17971895590123694473 -->\r\n",
       "<g id=\"node29\" class=\"node\"><title>17971895590123694473</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"171,-824 84,-824 84,-780 171,-780 171,-824\"/>\r\n",
       "<text text-anchor=\"start\" x=\"92.5\" y=\"-808\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Xception Module</text>\r\n",
       "<text text-anchor=\"start\" x=\"157.5\" y=\"-787\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x8</text>\r\n",
       "</g>\r\n",
       "<!-- add_2/add&#45;&gt;17971895590123694473 -->\r\n",
       "<g id=\"edge30\" class=\"edge\"><title>add_2/add&#45;&gt;17971895590123694473</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M127.5,-870.799C127.5,-860.369 127.5,-846.742 127.5,-834.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"131,-834.09 127.5,-824.09 124,-834.09 131,-834.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"155\" y=\"-845\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x25x25x728</text>\r\n",
       "</g>\r\n",
       "<!-- block13_pool/MaxPool -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>block13_pool/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"265.5,-617 185.5,-617 185.5,-581 265.5,-581 265.5,-617\"/>\r\n",
       "<text text-anchor=\"start\" x=\"193.5\" y=\"-596\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- add_11/add -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>add_11/add</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"169.5,-534 115.5,-534 115.5,-498 169.5,-498 169.5,-534\"/>\r\n",
       "<text text-anchor=\"start\" x=\"134.5\" y=\"-513\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Add</text>\r\n",
       "</g>\r\n",
       "<!-- block13_pool/MaxPool&#45;&gt;add_11/add -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>block13_pool/MaxPool&#45;&gt;add_11/add</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M207.898,-580.822C196.123,-569.331 180.455,-554.041 167.407,-541.307\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"169.678,-538.633 160.077,-534.153 164.789,-543.642 169.678,-538.633\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"219\" y=\"-555\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x13x13x1024</text>\r\n",
       "</g>\r\n",
       "<!-- 7694196470016349452 -->\r\n",
       "<g id=\"node23\" class=\"node\"><title>7694196470016349452</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"244.5,-451 40.5,-451 40.5,-415 244.5,-415 244.5,-451\"/>\r\n",
       "<text text-anchor=\"start\" x=\"48.5\" y=\"-430\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; Conv1x1 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- add_11/add&#45;&gt;7694196470016349452 -->\r\n",
       "<g id=\"edge20\" class=\"edge\"><title>add_11/add&#45;&gt;7694196470016349452</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M142.5,-497.822C142.5,-487.19 142.5,-473.306 142.5,-461.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"146,-461.153 142.5,-451.153 139,-461.153 146,-461.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"173\" y=\"-472\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x13x13x1024</text>\r\n",
       "</g>\r\n",
       "<!-- block14_sepconv2_act/Relu -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>block14_sepconv2_act/Relu</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"169.5,-285 115.5,-285 115.5,-249 169.5,-249 169.5,-285\"/>\r\n",
       "<text text-anchor=\"start\" x=\"133.5\" y=\"-264\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu</text>\r\n",
       "</g>\r\n",
       "<!-- avg_pool/Mean -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>avg_pool/Mean</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"169.5,-202 115.5,-202 115.5,-166 169.5,-166 169.5,-202\"/>\r\n",
       "<text text-anchor=\"start\" x=\"130.5\" y=\"-181\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Mean</text>\r\n",
       "</g>\r\n",
       "<!-- block14_sepconv2_act/Relu&#45;&gt;avg_pool/Mean -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>block14_sepconv2_act/Relu&#45;&gt;avg_pool/Mean</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M142.5,-248.822C142.5,-238.19 142.5,-224.306 142.5,-212.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"146,-212.153 142.5,-202.153 139,-212.153 146,-212.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"173\" y=\"-223\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x13x13x2048</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/MatMul -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>predictions/MatMul</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"169.5,-119 115.5,-119 115.5,-83 169.5,-83 169.5,-119\"/>\r\n",
       "<text text-anchor=\"start\" x=\"129.5\" y=\"-98\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Linear</text>\r\n",
       "</g>\r\n",
       "<!-- avg_pool/Mean&#45;&gt;predictions/MatMul -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>avg_pool/Mean&#45;&gt;predictions/MatMul</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M142.5,-165.822C142.5,-155.19 142.5,-141.306 142.5,-129.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"146,-129.153 142.5,-119.153 139,-129.153 146,-129.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"158\" y=\"-140\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x2048</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/Softmax -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>predictions/Softmax</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"169.5,-36 115.5,-36 115.5,-0 169.5,-0 169.5,-36\"/>\r\n",
       "<text text-anchor=\"start\" x=\"124.5\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Softmax</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/MatMul&#45;&gt;predictions/Softmax -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>predictions/MatMul&#45;&gt;predictions/Softmax</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M142.5,-82.822C142.5,-72.1903 142.5,-58.306 142.5,-46.2035\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"146,-46.1532 142.5,-36.1533 139,-46.1533 146,-46.1532\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"158\" y=\"-57\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1000</text>\r\n",
       "</g>\r\n",
       "<!-- 8613720893937014618&#45;&gt;block1_conv1_act/Relu -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>8613720893937014618&#45;&gt;block1_conv1_act/Relu</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M119.5,-2040.82C119.5,-2030.19 119.5,-2016.31 119.5,-2004.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"123,-2004.15 119.5,-1994.15 116,-2004.15 123,-2004.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"150\" y=\"-2015\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x199x199x32</text>\r\n",
       "</g>\r\n",
       "<!-- 3905769776342706844&#45;&gt;block1_conv2_act/Relu -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>3905769776342706844&#45;&gt;block1_conv2_act/Relu</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M119.5,-1874.82C119.5,-1864.19 119.5,-1850.31 119.5,-1838.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"123,-1838.15 119.5,-1828.15 116,-1838.15 123,-1838.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"150\" y=\"-1849\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x197x197x64</text>\r\n",
       "</g>\r\n",
       "<!-- 16674503091031775128&#45;&gt;add/add -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>16674503091031775128&#45;&gt;add/add</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M64.7756,-1654.89C69.7943,-1617.17 81.8469,-1526.56 87.9012,-1481.05\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"91.3857,-1481.4 89.235,-1471.03 84.4468,-1480.48 91.3857,-1481.4\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"103\" y=\"-1575\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x99x99x128</text>\r\n",
       "</g>\r\n",
       "<!-- 8666875710014757387&#45;&gt;add_1/add -->\r\n",
       "<g id=\"edge15\" class=\"edge\"><title>8666875710014757387&#45;&gt;add_1/add</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.2405,-1289.86C73.7696,-1275.34 77.9687,-1254.07 83.5,-1236 87.3553,-1223.41 92.688,-1209.84 97.521,-1198.45\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"100.816,-1199.65 101.59,-1189.08 94.3953,-1196.86 100.816,-1199.65\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"111\" y=\"-1251.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x50x50x256</text>\r\n",
       "</g>\r\n",
       "<!-- 16814389691786605164&#45;&gt;add_2/add -->\r\n",
       "<g id=\"edge17\" class=\"edge\"><title>16814389691786605164&#45;&gt;add_2/add</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M89.2405,-1007.86C91.7696,-993.34 95.9687,-972.07 101.5,-954 105.355,-941.405 110.688,-927.838 115.521,-916.45\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"118.816,-917.65 119.59,-907.083 112.395,-914.861 118.816,-917.65\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"129\" y=\"-969.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x25x25x728</text>\r\n",
       "</g>\r\n",
       "<!-- 10818282597484352154 -->\r\n",
       "<g id=\"node21\" class=\"node\"><title>10818282597484352154</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"164,-671 39,-671 39,-635 164,-635 164,-671\"/>\r\n",
       "<text text-anchor=\"start\" x=\"47.5\" y=\"-650\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1/s2 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- 10818282597484352154&#45;&gt;add_11/add -->\r\n",
       "<g id=\"edge18\" class=\"edge\"><title>10818282597484352154&#45;&gt;add_11/add</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M103.877,-634.831C106.127,-620.299 109.986,-599.021 115.5,-581 119.375,-568.335 124.895,-554.758 129.935,-543.381\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"133.234,-544.581 134.187,-534.029 126.862,-541.684 133.234,-544.581\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"146\" y=\"-596.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x13x13x1024</text>\r\n",
       "</g>\r\n",
       "<!-- 16865460990348038857 -->\r\n",
       "<g id=\"node24\" class=\"node\"><title>16865460990348038857</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"325.5,-1637 89.5,-1637 89.5,-1601 325.5,-1601 325.5,-1637\"/>\r\n",
       "<text text-anchor=\"start\" x=\"97.5\" y=\"-1616\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu &gt; SeparableConv3x3 &gt; Conv1x1 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- 2855760635569220863&#45;&gt;16865460990348038857 -->\r\n",
       "<g id=\"edge21\" class=\"edge\"><title>2855760635569220863&#45;&gt;16865460990348038857</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M204.982,-1708.97C205.452,-1692.38 206.173,-1666.88 206.724,-1647.43\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"210.225,-1647.44 207.009,-1637.34 203.228,-1647.24 210.225,-1647.44\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"238.5\" y=\"-1670.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x197x197x128</text>\r\n",
       "</g>\r\n",
       "<!-- 2355287610773706366 -->\r\n",
       "<g id=\"node25\" class=\"node\"><title>2355287610773706366</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"260.5,-368 24.5,-368 24.5,-332 260.5,-332 260.5,-368\"/>\r\n",
       "<text text-anchor=\"start\" x=\"32.5\" y=\"-347\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu &gt; SeparableConv3x3 &gt; Conv1x1 &gt; BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- 7694196470016349452&#45;&gt;2355287610773706366 -->\r\n",
       "<g id=\"edge23\" class=\"edge\"><title>7694196470016349452&#45;&gt;2355287610773706366</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M142.5,-414.822C142.5,-404.19 142.5,-390.306 142.5,-378.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"146,-378.153 142.5,-368.153 139,-378.153 146,-378.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"173\" y=\"-389\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x13x13x1536</text>\r\n",
       "</g>\r\n",
       "<!-- 16865460990348038857&#45;&gt;block2_pool/MaxPool -->\r\n",
       "<g id=\"edge22\" class=\"edge\"><title>16865460990348038857&#45;&gt;block2_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M195.624,-1600.82C187.902,-1589.65 177.699,-1574.9 169.05,-1562.38\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"171.925,-1560.39 163.359,-1554.15 166.167,-1564.37 171.925,-1560.39\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"215.5\" y=\"-1575\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x197x197x128</text>\r\n",
       "</g>\r\n",
       "<!-- 2355287610773706366&#45;&gt;block14_sepconv2_act/Relu -->\r\n",
       "<g id=\"edge24\" class=\"edge\"><title>2355287610773706366&#45;&gt;block14_sepconv2_act/Relu</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M142.5,-331.822C142.5,-321.19 142.5,-307.306 142.5,-295.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"146,-295.153 142.5,-285.153 139,-295.153 146,-295.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"173\" y=\"-306\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x13x13x2048</text>\r\n",
       "</g>\r\n",
       "<!-- 4833487269871428874&#45;&gt;block3_pool/MaxPool -->\r\n",
       "<g id=\"edge26\" class=\"edge\"><title>4833487269871428874&#45;&gt;block3_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M196.379,-1343.79C194.628,-1326.28 192.13,-1301.3 190.23,-1282.3\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"193.695,-1281.77 189.217,-1272.17 186.73,-1282.47 193.695,-1281.77\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"221\" y=\"-1305.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x99x99x256</text>\r\n",
       "</g>\r\n",
       "<!-- 13388773562632226509&#45;&gt;block4_pool/MaxPool -->\r\n",
       "<g id=\"edge28\" class=\"edge\"><title>13388773562632226509&#45;&gt;block4_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M214.379,-1061.79C212.628,-1044.28 210.13,-1019.3 208.23,-1000.3\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"211.695,-999.774 207.217,-990.172 204.73,-1000.47 211.695,-999.774\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"239\" y=\"-1023.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x50x50x728</text>\r\n",
       "</g>\r\n",
       "<!-- 7127121843796486060 -->\r\n",
       "<g id=\"node28\" class=\"node\"><title>7127121843796486060</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"352.5,-733 116.5,-733 116.5,-689 352.5,-689 352.5,-733\"/>\r\n",
       "<text text-anchor=\"start\" x=\"124.5\" y=\"-717\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu &gt; SeparableConv3x3 &gt; Conv1x1 &gt; BatchNorm</text>\r\n",
       "<text text-anchor=\"start\" x=\"338.5\" y=\"-696\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- 7127121843796486060&#45;&gt;block13_pool/MaxPool -->\r\n",
       "<g id=\"edge29\" class=\"edge\"><title>7127121843796486060&#45;&gt;block13_pool/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M232.765,-688.791C231.332,-671.278 229.288,-646.304 227.734,-627.3\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"231.209,-626.854 226.905,-617.172 224.232,-627.425 231.209,-626.854\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"258\" y=\"-650.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x25x25x728</text>\r\n",
       "</g>\r\n",
       "<!-- 17971895590123694473&#45;&gt;10818282597484352154 -->\r\n",
       "<g id=\"edge31\" class=\"edge\"><title>17971895590123694473&#45;&gt;10818282597484352154</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M120.91,-779.984C119.12,-774.169 117.206,-767.849 115.5,-762 111.756,-749.165 109.795,-746.172 107.5,-733 104.537,-715.99 103.037,-696.666 102.278,-681.388\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"105.761,-680.914 101.845,-671.069 98.767,-681.207 105.761,-680.914\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"143\" y=\"-754\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x25x25x728</text>\r\n",
       "</g>\r\n",
       "<!-- 17971895590123694473&#45;&gt;7127121843796486060 -->\r\n",
       "<g id=\"edge32\" class=\"edge\"><title>17971895590123694473&#45;&gt;7127121843796486060</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M152.858,-779.908C167.277,-767.914 185.51,-752.749 201.085,-739.794\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"203.504,-742.334 208.954,-733.249 199.027,-736.953 203.504,-742.334\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"214\" y=\"-754\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x25x25x728</text>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<hiddenlayer.graph.Graph at 0x174209923c8>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Define custom transforms to group nodes of the Xception module\n",
    "transforms = [\n",
    "    # Build basic folds first\n",
    "    ht.Fold(\"Conv > BatchNorm\", \"ConvBn\"),\n",
    "    # ht.Fold(\"ConvBn > Relu\", \"ConvBnRelu\"),\n",
    "    # Next, build higher level folds that use basic folds\n",
    "    ht.Fold(\"SeparableConv > ConvBn\", \"SepConvConvBn\"),\n",
    "    ht.Fold(\"Relu > SepConvConvBn\", \"ReluSepConvConvBn\"),\n",
    "    # Finally, build the Xception module\n",
    "    ht.Fold(\"ReluSepConvConvBn > ReluSepConvConvBn > ReluSepConvConvBn > Add\", \"Xception\", \"Xception Module\"),\n",
    "    # Fold repeated nodes\n",
    "    ht.FoldDuplicates(),\n",
    "]\n",
    "\n",
    "# Build model graph view\n",
    "hl_graph = hl.build_graph(K.get_session().graph, transforms=transforms)\n",
    "\n",
    "# Display graph view\n",
    "hl_graph"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## ResNet50 with Bottleneck and Residual blocks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a new graph and set the learning phase to inference\n",
    "K.clear_session()\n",
    "K.set_learning_phase(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Build the model\n",
    "model = ResNet50(input_shape=(224, 224, 3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: %3 Pages: 1 -->\r\n",
       "<svg width=\"301pt\" height=\"1302pt\"\r\n",
       " viewBox=\"0.00 0.00 301.00 1302.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 1266)\">\r\n",
       "<title>%3</title>\r\n",
       "<polygon fill=\"#ffffff\" stroke=\"none\" points=\"-72,36 -72,-1266 229,-1266 229,36 -72,36\"/>\r\n",
       "<!-- input_1 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>input_1</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"111.5,-1230 45.5,-1230 45.5,-1194 111.5,-1194 111.5,-1230\"/>\r\n",
       "<text text-anchor=\"start\" x=\"53.5\" y=\"-1209\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Placeholder</text>\r\n",
       "</g>\r\n",
       "<!-- 11280129244922539850 -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>11280129244922539850</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"157,-1147 0,-1147 0,-1111 157,-1111 157,-1147\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-1126\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv7x7/s2 &gt; BatchNorm &gt; Relu</text>\r\n",
       "</g>\r\n",
       "<!-- input_1&#45;&gt;11280129244922539850 -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>input_1&#45;&gt;11280129244922539850</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-1193.82C78.5,-1183.19 78.5,-1169.31 78.5,-1157.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-1157.15 78.5,-1147.15 75.0001,-1157.15 82.0001,-1157.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"106\" y=\"-1168\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x224x224x3</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d/MaxPool -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>max_pooling2d/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"118.5,-1064 38.5,-1064 38.5,-1028 118.5,-1028 118.5,-1064\"/>\r\n",
       "<text text-anchor=\"start\" x=\"46.5\" y=\"-1043\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 8724259298094990576 -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>8724259298094990576</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"121,-981 36,-981 36,-945 121,-945 121,-981\"/>\r\n",
       "<text text-anchor=\"start\" x=\"44.5\" y=\"-960\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Bottleneck Block</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d/MaxPool&#45;&gt;8724259298094990576 -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>max_pooling2d/MaxPool&#45;&gt;8724259298094990576</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-1027.82C78.5,-1017.19 78.5,-1003.31 78.5,-991.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-991.153 78.5,-981.153 75.0001,-991.153 82.0001,-991.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"103.5\" y=\"-1002\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x55x55x64</text>\r\n",
       "</g>\r\n",
       "<!-- avg_pool/AvgPool -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>avg_pool/AvgPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"118,-285 39,-285 39,-249 118,-249 118,-285\"/>\r\n",
       "<text text-anchor=\"start\" x=\"47.5\" y=\"-264\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">AvgPool7x7/s7</text>\r\n",
       "</g>\r\n",
       "<!-- flatten/Reshape -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>flatten/Reshape</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"105.5,-202 51.5,-202 51.5,-166 105.5,-166 105.5,-202\"/>\r\n",
       "<text text-anchor=\"start\" x=\"60.5\" y=\"-181\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Reshape</text>\r\n",
       "</g>\r\n",
       "<!-- avg_pool/AvgPool&#45;&gt;flatten/Reshape -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>avg_pool/AvgPool&#45;&gt;flatten/Reshape</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-248.822C78.5,-238.19 78.5,-224.306 78.5,-212.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-212.153 78.5,-202.153 75.0001,-212.153 82.0001,-212.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"103.5\" y=\"-223\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x2048</text>\r\n",
       "</g>\r\n",
       "<!-- fc1000/MatMul -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>fc1000/MatMul</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"105.5,-119 51.5,-119 51.5,-83 105.5,-83 105.5,-119\"/>\r\n",
       "<text text-anchor=\"start\" x=\"65.5\" y=\"-98\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Linear</text>\r\n",
       "</g>\r\n",
       "<!-- flatten/Reshape&#45;&gt;fc1000/MatMul -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>flatten/Reshape&#45;&gt;fc1000/MatMul</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-165.822C78.5,-155.19 78.5,-141.306 78.5,-129.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-129.153 78.5,-119.153 75.0001,-129.153 82.0001,-129.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"94\" y=\"-140\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x2048</text>\r\n",
       "</g>\r\n",
       "<!-- fc1000/Softmax -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>fc1000/Softmax</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"105.5,-36 51.5,-36 51.5,-0 105.5,-0 105.5,-36\"/>\r\n",
       "<text text-anchor=\"start\" x=\"60.5\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Softmax</text>\r\n",
       "</g>\r\n",
       "<!-- fc1000/MatMul&#45;&gt;fc1000/Softmax -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>fc1000/MatMul&#45;&gt;fc1000/Softmax</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-82.822C78.5,-72.1903 78.5,-58.306 78.5,-46.2035\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-46.1532 78.5,-36.1533 75.0001,-46.1533 82.0001,-46.1532\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"94\" y=\"-57\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1000</text>\r\n",
       "</g>\r\n",
       "<!-- 11280129244922539850&#45;&gt;max_pooling2d/MaxPool -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>11280129244922539850&#45;&gt;max_pooling2d/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-1110.82C78.5,-1100.19 78.5,-1086.31 78.5,-1074.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-1074.15 78.5,-1064.15 75.0001,-1074.15 82.0001,-1074.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"109\" y=\"-1085\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x112x112x64</text>\r\n",
       "</g>\r\n",
       "<!-- 15797068418753118859 -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>15797068418753118859</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"117,-898 40,-898 40,-854 117,-854 117,-898\"/>\r\n",
       "<text text-anchor=\"start\" x=\"48.5\" y=\"-882\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Residual Block</text>\r\n",
       "<text text-anchor=\"start\" x=\"103.5\" y=\"-861\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- 8724259298094990576&#45;&gt;15797068418753118859 -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>8724259298094990576&#45;&gt;15797068418753118859</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-944.799C78.5,-934.369 78.5,-920.742 78.5,-908.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-908.09 78.5,-898.09 75.0001,-908.09 82.0001,-908.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"106\" y=\"-919\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x55x55x256</text>\r\n",
       "</g>\r\n",
       "<!-- 12946653020198380528 -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>12946653020198380528</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"121,-807 36,-807 36,-771 121,-771 121,-807\"/>\r\n",
       "<text text-anchor=\"start\" x=\"44.5\" y=\"-786\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Bottleneck Block</text>\r\n",
       "</g>\r\n",
       "<!-- 15748497814034426050 -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>15748497814034426050</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"117,-724 40,-724 40,-680 117,-680 117,-724\"/>\r\n",
       "<text text-anchor=\"start\" x=\"48.5\" y=\"-708\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Residual Block</text>\r\n",
       "<text text-anchor=\"start\" x=\"103.5\" y=\"-687\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x3</text>\r\n",
       "</g>\r\n",
       "<!-- 12946653020198380528&#45;&gt;15748497814034426050 -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>12946653020198380528&#45;&gt;15748497814034426050</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-770.799C78.5,-760.369 78.5,-746.742 78.5,-734.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-734.09 78.5,-724.09 75.0001,-734.09 82.0001,-734.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"106\" y=\"-745\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x512</text>\r\n",
       "</g>\r\n",
       "<!-- 16726519431455799345 -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>16726519431455799345</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"121,-633 36,-633 36,-597 121,-597 121,-633\"/>\r\n",
       "<text text-anchor=\"start\" x=\"44.5\" y=\"-612\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Bottleneck Block</text>\r\n",
       "</g>\r\n",
       "<!-- 16499243899165472698 -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>16499243899165472698</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"117,-550 40,-550 40,-506 117,-506 117,-550\"/>\r\n",
       "<text text-anchor=\"start\" x=\"48.5\" y=\"-534\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Residual Block</text>\r\n",
       "<text text-anchor=\"start\" x=\"103.5\" y=\"-513\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x5</text>\r\n",
       "</g>\r\n",
       "<!-- 16726519431455799345&#45;&gt;16499243899165472698 -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>16726519431455799345&#45;&gt;16499243899165472698</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-596.799C78.5,-586.369 78.5,-572.742 78.5,-560.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-560.09 78.5,-550.09 75.0001,-560.09 82.0001,-560.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"109\" y=\"-571\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x1024</text>\r\n",
       "</g>\r\n",
       "<!-- 4780165852433535183 -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>4780165852433535183</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"121,-459 36,-459 36,-423 121,-423 121,-459\"/>\r\n",
       "<text text-anchor=\"start\" x=\"44.5\" y=\"-438\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Bottleneck Block</text>\r\n",
       "</g>\r\n",
       "<!-- 1702985634185393050 -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>1702985634185393050</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"117,-376 40,-376 40,-332 117,-332 117,-376\"/>\r\n",
       "<text text-anchor=\"start\" x=\"48.5\" y=\"-360\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Residual Block</text>\r\n",
       "<text text-anchor=\"start\" x=\"103.5\" y=\"-339\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- 4780165852433535183&#45;&gt;1702985634185393050 -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>4780165852433535183&#45;&gt;1702985634185393050</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-422.799C78.5,-412.369 78.5,-398.742 78.5,-386.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-386.09 78.5,-376.09 75.0001,-386.09 82.0001,-386.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"103.5\" y=\"-397\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x2048</text>\r\n",
       "</g>\r\n",
       "<!-- 15797068418753118859&#45;&gt;12946653020198380528 -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>15797068418753118859&#45;&gt;12946653020198380528</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-853.989C78.5,-842.923 78.5,-829.219 78.5,-817.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-817.062 78.5,-807.062 75.0001,-817.062 82.0001,-817.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"106\" y=\"-828\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x55x55x256</text>\r\n",
       "</g>\r\n",
       "<!-- 1702985634185393050&#45;&gt;avg_pool/AvgPool -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>1702985634185393050&#45;&gt;avg_pool/AvgPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-331.989C78.5,-320.923 78.5,-307.219 78.5,-295.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-295.062 78.5,-285.062 75.0001,-295.062 82.0001,-295.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"103.5\" y=\"-306\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x2048</text>\r\n",
       "</g>\r\n",
       "<!-- 15748497814034426050&#45;&gt;16726519431455799345 -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>15748497814034426050&#45;&gt;16726519431455799345</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-679.989C78.5,-668.923 78.5,-655.219 78.5,-643.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-643.062 78.5,-633.062 75.0001,-643.062 82.0001,-643.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"106\" y=\"-654\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x512</text>\r\n",
       "</g>\r\n",
       "<!-- 16499243899165472698&#45;&gt;4780165852433535183 -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>16499243899165472698&#45;&gt;4780165852433535183</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.5,-505.989C78.5,-494.923 78.5,-481.219 78.5,-469.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"82.0001,-469.062 78.5,-459.062 75.0001,-469.062 82.0001,-469.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"109\" y=\"-480\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x1024</text>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<hiddenlayer.graph.Graph at 0x17426ed9518>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Define custom transforms to group nodes of the bottleneck and residual blocks\n",
    "transforms = [\n",
    "    # Build basic folds first\n",
    "    ht.Fold(\"Conv > BatchNorm\", \"ConvBn\"),\n",
    "    ht.Fold(\"ConvBn > Relu\", \"ConvBnRelu\"),\n",
    "    # Fold bottleneck blocks\n",
    "    ht.Fold(\"((ConvBnRelu > ConvBnRelu > ConvBn) | ConvBn) > Add > Relu\", \"BottleneckBlock\", \"Bottleneck Block\"),\n",
    "    # Fold residual blocks\n",
    "    ht.Fold(\"ConvBnRelu > ConvBnRelu > ConvBn > Add > Relu\", \"ResBlock\", \"Residual Block\"),\n",
    "    ht.FoldDuplicates(),\n",
    "]\n",
    "\n",
    "# Build model graph view and display it\n",
    "hl_graph = hl.build_graph(K.get_session().graph, transforms=transforms)\n",
    "hl_graph"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## InceptionV3 with 3 Types of Inception Modules"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a new graph and set the learning phase to inference\n",
    "K.clear_session()\n",
    "K.set_learning_phase(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: %3 Pages: 1 -->\r\n",
       "<svg width=\"561pt\" height=\"1326pt\"\r\n",
       " viewBox=\"0.00 0.00 560.50 1326.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 1290)\">\r\n",
       "<title>%3</title>\r\n",
       "<polygon fill=\"#ffffff\" stroke=\"none\" points=\"-72,36 -72,-1290 488.5,-1290 488.5,36 -72,36\"/>\r\n",
       "<!-- input_1 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>input_1</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"210,-1254 144,-1254 144,-1218 210,-1218 210,-1254\"/>\r\n",
       "<text text-anchor=\"start\" x=\"152\" y=\"-1233\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Placeholder</text>\r\n",
       "</g>\r\n",
       "<!-- 10066043589950649508 -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>10066043589950649508</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"255.5,-1171 98.5,-1171 98.5,-1127 255.5,-1127 255.5,-1171\"/>\r\n",
       "<text text-anchor=\"start\" x=\"107\" y=\"-1155\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv3x3/s2 &gt; BatchNorm &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"242\" y=\"-1134\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x3</text>\r\n",
       "</g>\r\n",
       "<!-- input_1&#45;&gt;10066043589950649508 -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>input_1&#45;&gt;10066043589950649508</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-1217.8C177,-1207.37 177,-1193.74 177,-1181.44\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-1181.09 177,-1171.09 173.5,-1181.09 180.5,-1181.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"204.5\" y=\"-1192\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x299x299x3</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d/MaxPool -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>max_pooling2d/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"217,-1080 137,-1080 137,-1044 217,-1044 217,-1080\"/>\r\n",
       "<text text-anchor=\"start\" x=\"145\" y=\"-1059\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 13227311844436384767 -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>13227311844436384767</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"248.5,-997 105.5,-997 105.5,-953 248.5,-953 248.5,-997\"/>\r\n",
       "<text text-anchor=\"start\" x=\"114\" y=\"-981\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"235\" y=\"-960\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d/MaxPool&#45;&gt;13227311844436384767 -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>max_pooling2d/MaxPool&#45;&gt;13227311844436384767</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-1043.8C177,-1033.37 177,-1019.74 177,-1007.44\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-1007.09 177,-997.09 173.5,-1007.09 180.5,-1007.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"202\" y=\"-1018\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x73x73x64</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d_1/MaxPool -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>max_pooling2d_1/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"217,-906 137,-906 137,-870 217,-870 217,-906\"/>\r\n",
       "<text text-anchor=\"start\" x=\"145\" y=\"-885\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 2502790684225966957 -->\r\n",
       "<g id=\"node18\" class=\"node\"><title>2502790684225966957</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"233.5,-823 120.5,-823 120.5,-779 233.5,-779 233.5,-823\"/>\r\n",
       "<text text-anchor=\"start\" x=\"129\" y=\"-807\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Inception&#45;V3 Module A</text>\r\n",
       "<text text-anchor=\"start\" x=\"220\" y=\"-786\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x3</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d_1/MaxPool&#45;&gt;2502790684225966957 -->\r\n",
       "<g id=\"edge15\" class=\"edge\"><title>max_pooling2d_1/MaxPool&#45;&gt;2502790684225966957</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-869.799C177,-859.369 177,-845.742 177,-833.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-833.09 177,-823.09 173.5,-833.09 180.5,-833.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"204.5\" y=\"-844\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x35x35x192</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d_2/MaxPool -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>max_pooling2d_2/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"80,-728 0,-728 0,-692 80,-692 80,-728\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8\" y=\"-707\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- mixed3/concat -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>mixed3/concat</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"204,-641 150,-641 150,-605 204,-605 204,-641\"/>\r\n",
       "<text text-anchor=\"start\" x=\"162\" y=\"-620\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Concat</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d_2/MaxPool&#45;&gt;mixed3/concat -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>max_pooling2d_2/MaxPool&#45;&gt;mixed3/concat</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M66.2129,-691.877C81.2815,-682.114 100.614,-669.725 118,-659 125.431,-654.416 133.445,-649.587 141.098,-645.029\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"143.043,-647.945 149.86,-639.835 139.473,-641.924 143.043,-647.945\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"145.5\" y=\"-662\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x17x17x288</text>\r\n",
       "</g>\r\n",
       "<!-- 5920259893028631852 -->\r\n",
       "<g id=\"node19\" class=\"node\"><title>5920259893028631852</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"233.5,-558 120.5,-558 120.5,-514 233.5,-514 233.5,-558\"/>\r\n",
       "<text text-anchor=\"start\" x=\"129\" y=\"-542\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Inception&#45;V3 Module B</text>\r\n",
       "<text text-anchor=\"start\" x=\"220\" y=\"-521\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x4</text>\r\n",
       "</g>\r\n",
       "<!-- mixed3/concat&#45;&gt;5920259893028631852 -->\r\n",
       "<g id=\"edge19\" class=\"edge\"><title>mixed3/concat&#45;&gt;5920259893028631852</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-604.799C177,-594.369 177,-580.742 177,-568.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-568.09 177,-558.09 173.5,-568.09 180.5,-568.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"204.5\" y=\"-579\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x17x17x768</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d_3/MaxPool -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>max_pooling2d_3/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"87,-463 7,-463 7,-427 87,-427 87,-463\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15\" y=\"-442\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- mixed8/concat -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>mixed8/concat</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"204,-376 150,-376 150,-340 204,-340 204,-376\"/>\r\n",
       "<text text-anchor=\"start\" x=\"162\" y=\"-355\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Concat</text>\r\n",
       "</g>\r\n",
       "<!-- max_pooling2d_3/MaxPool&#45;&gt;mixed8/concat -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>max_pooling2d_3/MaxPool&#45;&gt;mixed8/concat</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M73.3074,-426.799C93.1307,-413.838 120.503,-395.941 142.147,-381.789\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"144.277,-384.577 150.732,-376.175 140.447,-378.719 144.277,-384.577\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"142.5\" y=\"-397\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x8x8x768</text>\r\n",
       "</g>\r\n",
       "<!-- 4481992666862408784 -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>4481992666862408784</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"233.5,-293 120.5,-293 120.5,-249 233.5,-249 233.5,-293\"/>\r\n",
       "<text text-anchor=\"start\" x=\"129\" y=\"-277\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Inception&#45;V3 Module C</text>\r\n",
       "<text text-anchor=\"start\" x=\"220\" y=\"-256\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- mixed8/concat&#45;&gt;4481992666862408784 -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>mixed8/concat&#45;&gt;4481992666862408784</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-339.799C177,-329.369 177,-315.742 177,-303.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-303.09 177,-293.09 173.5,-303.09 180.5,-303.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"202\" y=\"-314\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x8x8x1280</text>\r\n",
       "</g>\r\n",
       "<!-- avg_pool/Mean -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>avg_pool/Mean</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"204,-202 150,-202 150,-166 204,-166 204,-202\"/>\r\n",
       "<text text-anchor=\"start\" x=\"165\" y=\"-181\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Mean</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/MatMul -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>predictions/MatMul</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"204,-119 150,-119 150,-83 204,-83 204,-119\"/>\r\n",
       "<text text-anchor=\"start\" x=\"164\" y=\"-98\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Linear</text>\r\n",
       "</g>\r\n",
       "<!-- avg_pool/Mean&#45;&gt;predictions/MatMul -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>avg_pool/Mean&#45;&gt;predictions/MatMul</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-165.822C177,-155.19 177,-141.306 177,-129.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-129.153 177,-119.153 173.5,-129.153 180.5,-129.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"192.5\" y=\"-140\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x2048</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/Softmax -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>predictions/Softmax</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"204,-36 150,-36 150,-0 204,-0 204,-36\"/>\r\n",
       "<text text-anchor=\"start\" x=\"159\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Softmax</text>\r\n",
       "</g>\r\n",
       "<!-- predictions/MatMul&#45;&gt;predictions/Softmax -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>predictions/MatMul&#45;&gt;predictions/Softmax</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-82.822C177,-72.1903 177,-58.306 177,-46.2035\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-46.1532 177,-36.1533 173.5,-46.1533 180.5,-46.1532\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"192.5\" y=\"-57\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1000</text>\r\n",
       "</g>\r\n",
       "<!-- 13067925692227544297 -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>13067925692227544297</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"255.5,-728 98.5,-728 98.5,-692 255.5,-692 255.5,-728\"/>\r\n",
       "<text text-anchor=\"start\" x=\"107\" y=\"-707\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv3x3/s2 &gt; BatchNorm &gt; Relu</text>\r\n",
       "</g>\r\n",
       "<!-- 13067925692227544297&#45;&gt;mixed3/concat -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>13067925692227544297&#45;&gt;mixed3/concat</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-691.799C177,-680.163 177,-664.548 177,-651.237\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-651.175 177,-641.175 173.5,-651.175 180.5,-651.175\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"204.5\" y=\"-662\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x17x17x384</text>\r\n",
       "</g>\r\n",
       "<!-- 13227311844436384767&#45;&gt;max_pooling2d_1/MaxPool -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>13227311844436384767&#45;&gt;max_pooling2d_1/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-952.989C177,-941.923 177,-928.219 177,-916.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-916.062 177,-906.062 173.5,-916.062 180.5,-916.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"202\" y=\"-927\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x73x73x80</text>\r\n",
       "</g>\r\n",
       "<!-- 5359747554084775967 -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>5359747554084775967</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"248.5,-467 105.5,-467 105.5,-423 248.5,-423 248.5,-467\"/>\r\n",
       "<text text-anchor=\"start\" x=\"114\" y=\"-451\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"235\" y=\"-430\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x2</text>\r\n",
       "</g>\r\n",
       "<!-- 5359747554084775967&#45;&gt;mixed8/concat -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>5359747554084775967&#45;&gt;mixed8/concat</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-422.989C177,-411.923 177,-398.219 177,-386.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-386.062 177,-376.062 173.5,-386.062 180.5,-386.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"204.5\" y=\"-397\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x17x17x192</text>\r\n",
       "</g>\r\n",
       "<!-- 4481992666862408784&#45;&gt;avg_pool/Mean -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>4481992666862408784&#45;&gt;avg_pool/Mean</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-248.989C177,-237.923 177,-224.219 177,-212.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-212.062 177,-202.062 173.5,-212.062 180.5,-212.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"202\" y=\"-223\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x8x8x2048</text>\r\n",
       "</g>\r\n",
       "<!-- 10066043589950649508&#45;&gt;max_pooling2d/MaxPool -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>10066043589950649508&#45;&gt;max_pooling2d/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-1126.99C177,-1115.92 177,-1102.22 177,-1090.34\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-1090.06 177,-1080.06 173.5,-1090.06 180.5,-1090.06\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"207.5\" y=\"-1101\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x149x149x32</text>\r\n",
       "</g>\r\n",
       "<!-- 5005417435749980234 -->\r\n",
       "<g id=\"node16\" class=\"node\"><title>5005417435749980234</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"416.5,-732 273.5,-732 273.5,-688 416.5,-688 416.5,-732\"/>\r\n",
       "<text text-anchor=\"start\" x=\"282\" y=\"-716\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"403\" y=\"-695\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x3</text>\r\n",
       "</g>\r\n",
       "<!-- 5005417435749980234&#45;&gt;mixed3/concat -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>5005417435749980234&#45;&gt;mixed3/concat</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M303.472,-687.989C275.745,-673.96 239.639,-655.692 213.107,-642.268\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"214.654,-639.129 204.151,-637.737 211.494,-645.375 214.654,-639.129\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"292\" y=\"-662\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x35x35x64</text>\r\n",
       "</g>\r\n",
       "<!-- 3120678932507455542 -->\r\n",
       "<g id=\"node17\" class=\"node\"><title>3120678932507455542</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"409.5,-467 266.5,-467 266.5,-423 409.5,-423 409.5,-467\"/>\r\n",
       "<text text-anchor=\"start\" x=\"275\" y=\"-451\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; Relu</text>\r\n",
       "<text text-anchor=\"start\" x=\"396\" y=\"-430\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x4</text>\r\n",
       "</g>\r\n",
       "<!-- 3120678932507455542&#45;&gt;mixed8/concat -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>3120678932507455542&#45;&gt;mixed8/concat</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M298.202,-422.989C272.161,-409.24 238.408,-391.42 213.137,-378.079\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"214.718,-374.955 204.24,-373.382 211.449,-381.145 214.718,-374.955\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"290.5\" y=\"-397\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x17x17x192</text>\r\n",
       "</g>\r\n",
       "<!-- 2502790684225966957&#45;&gt;max_pooling2d_2/MaxPool -->\r\n",
       "<g id=\"edge16\" class=\"edge\"><title>2502790684225966957&#45;&gt;max_pooling2d_2/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M144.533,-778.908C123.53,-765.264 96.2101,-747.516 74.7671,-733.586\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"76.5632,-730.579 66.2706,-728.066 72.7497,-736.449 76.5632,-730.579\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"144.5\" y=\"-753\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x35x35x256</text>\r\n",
       "</g>\r\n",
       "<!-- 2502790684225966957&#45;&gt;13067925692227544297 -->\r\n",
       "<g id=\"edge17\" class=\"edge\"><title>2502790684225966957&#45;&gt;13067925692227544297</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-778.908C177,-766.78 177,-751.409 177,-738.36\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-738.066 177,-728.066 173.5,-738.066 180.5,-738.066\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"204.5\" y=\"-753\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x35x35x256</text>\r\n",
       "</g>\r\n",
       "<!-- 2502790684225966957&#45;&gt;5005417435749980234 -->\r\n",
       "<g id=\"edge18\" class=\"edge\"><title>2502790684225966957&#45;&gt;5005417435749980234</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M216.814,-778.908C240.579,-766.318 270.94,-750.234 296.149,-736.879\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"297.983,-739.869 305.181,-732.094 294.706,-733.683 297.983,-739.869\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"299.5\" y=\"-753\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x35x35x256</text>\r\n",
       "</g>\r\n",
       "<!-- 5920259893028631852&#45;&gt;max_pooling2d_3/MaxPool -->\r\n",
       "<g id=\"edge20\" class=\"edge\"><title>5920259893028631852&#45;&gt;max_pooling2d_3/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M144.733,-513.918C136.021,-508.159 126.621,-501.883 118,-496 105.274,-487.315 91.3934,-477.597 79.3086,-469.053\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"81.0511,-465.998 70.8685,-463.072 77.0035,-471.71 81.0511,-465.998\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"145.5\" y=\"-488\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x17x17x768</text>\r\n",
       "</g>\r\n",
       "<!-- 5920259893028631852&#45;&gt;5359747554084775967 -->\r\n",
       "<g id=\"edge21\" class=\"edge\"><title>5920259893028631852&#45;&gt;5359747554084775967</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M177,-513.908C177,-503.015 177,-489.505 177,-477.411\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"180.5,-477.249 177,-467.249 173.5,-477.249 180.5,-477.249\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"204.5\" y=\"-488\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x17x17x768</text>\r\n",
       "</g>\r\n",
       "<!-- 5920259893028631852&#45;&gt;3120678932507455542 -->\r\n",
       "<g id=\"edge22\" class=\"edge\"><title>5920259893028631852&#45;&gt;3120678932507455542</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M215.155,-513.908C237.83,-501.374 266.771,-485.375 290.866,-472.055\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"292.782,-474.996 299.84,-467.094 289.395,-468.869 292.782,-474.996\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"295.5\" y=\"-488\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x17x17x768</text>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<hiddenlayer.graph.Graph at 0x1744dce2cc0>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Build the model\n",
    "model = InceptionV3(input_shape=(299, 299, 3))\n",
    "\n",
    "# Define custom transforms to group nodes into modules\n",
    "transforms = [\n",
    "    # Build basic folds first\n",
    "    ht.Fold(\"Conv > BatchNorm\", \"ConvBn\"),\n",
    "    ht.Fold(\"ConvBn > Relu\", \"ConvBnRelu\"),\n",
    "    # Fold nodes into inception modules\n",
    "    ht.Fold(\"\"\"\n",
    "        ( (AvgPool > ConvBnRelu) |\n",
    "          (ConvBnRelu) |\n",
    "          (ConvBnRelu > ConvBnRelu) |\n",
    "          (ConvBnRelu > ConvBnRelu > ConvBnRelu)\n",
    "        ) > Concat\n",
    "        \"\"\", \"Inception-V3\", \"Inception-V3 Module A\"),\n",
    "    ht.Fold(\"\"\"\n",
    "        ( (AvgPool > ConvBnRelu) |\n",
    "          (ConvBnRelu) |\n",
    "          (ConvBnRelu > ConvBnRelu > ConvBnRelu) |\n",
    "          (ConvBnRelu > ConvBnRelu > ConvBnRelu > ConvBnRelu > ConvBnRelu)\n",
    "        ) > Concat\n",
    "        \"\"\", \"Inception-V3\", \"Inception-V3 Module B\"),\n",
    "    ht.Fold(\"\"\"\n",
    "        ( (AvgPool > ConvBnRelu) |\n",
    "          (ConvBnRelu) |\n",
    "          (ConvBnRelu > (ConvBnRelu | ConvBnRelu) > Concat) |\n",
    "          (ConvBnRelu > ConvBnRelu > (ConvBnRelu | ConvBnRelu) > Concat)\n",
    "        ) > Concat\n",
    "        \"\"\", \"Inception-V3\", \"Inception-V3 Module C\"),\n",
    "    ht.FoldDuplicates(),\n",
    "]\n",
    "\n",
    "# Build model graph view and display it\n",
    "hl_graph = hl.build_graph(K.get_session().graph, transforms=transforms)\n",
    "hl_graph"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## MobileNet with ReLU6"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a new graph and set the learning phase to inference\n",
    "K.clear_session()\n",
    "K.set_learning_phase(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: %3 Pages: 1 -->\r\n",
       "<svg width=\"353pt\" height=\"4258pt\"\r\n",
       " viewBox=\"0.00 0.00 353.00 4258.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 4222)\">\r\n",
       "<title>%3</title>\r\n",
       "<polygon fill=\"#ffffff\" stroke=\"none\" points=\"-72,36 -72,-4222 281,-4222 281,36 -72,36\"/>\r\n",
       "<!-- input_1 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>input_1</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"137.5,-4186 71.5,-4186 71.5,-4150 137.5,-4150 137.5,-4186\"/>\r\n",
       "<text text-anchor=\"start\" x=\"79.5\" y=\"-4165\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Placeholder</text>\r\n",
       "</g>\r\n",
       "<!-- conv1_pad/Pad -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>conv1_pad/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-4103 77.5,-4103 77.5,-4067 131.5,-4067 131.5,-4103\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-4082\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- input_1&#45;&gt;conv1_pad/Pad -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>input_1&#45;&gt;conv1_pad/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-4149.82C104.5,-4139.19 104.5,-4125.31 104.5,-4113.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-4113.15 104.5,-4103.15 101,-4113.15 108,-4113.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-4124\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x224x224x3</text>\r\n",
       "</g>\r\n",
       "<!-- 12149989648873824835 -->\r\n",
       "<g id=\"node25\" class=\"node\"><title>12149989648873824835</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"187,-4020 22,-4020 22,-3984 187,-3984 187,-4020\"/>\r\n",
       "<text text-anchor=\"start\" x=\"30.5\" y=\"-3999\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv3x3/s2 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv1_pad/Pad&#45;&gt;12149989648873824835 -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>conv1_pad/Pad&#45;&gt;12149989648873824835</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-4066.82C104.5,-4056.19 104.5,-4042.31 104.5,-4030.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-4030.15 104.5,-4020.15 101,-4030.15 108,-4030.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-4041\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x226x226x3</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_1/Pad -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>conv_pad_1/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-3937 77.5,-3937 77.5,-3901 131.5,-3901 131.5,-3937\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-3916\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 1476947437174655940 -->\r\n",
       "<g id=\"node39\" class=\"node\"><title>1476947437174655940</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-3854 7,-3854 7,-3818 202,-3818 202,-3854\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-3833\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_1/Pad&#45;&gt;1476947437174655940 -->\r\n",
       "<g id=\"edge27\" class=\"edge\"><title>conv_pad_1/Pad&#45;&gt;1476947437174655940</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3900.82C104.5,-3890.19 104.5,-3876.31 104.5,-3864.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3864.15 104.5,-3854.15 101,-3864.15 108,-3864.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"135\" y=\"-3875\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x114x114x32</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_2/Pad -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>conv_pad_2/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-3688 77.5,-3688 77.5,-3652 131.5,-3652 131.5,-3688\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-3667\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 11222317214380384061 -->\r\n",
       "<g id=\"node40\" class=\"node\"><title>11222317214380384061</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"209,-3605 0,-3605 0,-3569 209,-3569 209,-3605\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-3584\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3/s2 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_2/Pad&#45;&gt;11222317214380384061 -->\r\n",
       "<g id=\"edge29\" class=\"edge\"><title>conv_pad_2/Pad&#45;&gt;11222317214380384061</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3651.82C104.5,-3641.19 104.5,-3627.31 104.5,-3615.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3615.15 104.5,-3605.15 101,-3615.15 108,-3615.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"135\" y=\"-3626\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x114x114x64</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_3/Pad -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>conv_pad_3/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-3439 77.5,-3439 77.5,-3403 131.5,-3403 131.5,-3439\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-3418\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 8430071148413196380 -->\r\n",
       "<g id=\"node41\" class=\"node\"><title>8430071148413196380</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-3356 7,-3356 7,-3320 202,-3320 202,-3356\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-3335\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_3/Pad&#45;&gt;8430071148413196380 -->\r\n",
       "<g id=\"edge31\" class=\"edge\"><title>conv_pad_3/Pad&#45;&gt;8430071148413196380</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3402.82C104.5,-3392.19 104.5,-3378.31 104.5,-3366.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3366.15 104.5,-3356.15 101,-3366.15 108,-3366.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-3377\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x58x58x128</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_4/Pad -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>conv_pad_4/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-3190 77.5,-3190 77.5,-3154 131.5,-3154 131.5,-3190\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-3169\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 2224110879536963875 -->\r\n",
       "<g id=\"node42\" class=\"node\"><title>2224110879536963875</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"209,-3107 0,-3107 0,-3071 209,-3071 209,-3107\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-3086\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3/s2 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_4/Pad&#45;&gt;2224110879536963875 -->\r\n",
       "<g id=\"edge33\" class=\"edge\"><title>conv_pad_4/Pad&#45;&gt;2224110879536963875</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3153.82C104.5,-3143.19 104.5,-3129.31 104.5,-3117.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3117.15 104.5,-3107.15 101,-3117.15 108,-3117.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-3128\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x58x58x128</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_5/Pad -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>conv_pad_5/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-2941 77.5,-2941 77.5,-2905 131.5,-2905 131.5,-2941\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-2920\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 16910846413449957553 -->\r\n",
       "<g id=\"node43\" class=\"node\"><title>16910846413449957553</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-2858 7,-2858 7,-2822 202,-2822 202,-2858\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-2837\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_5/Pad&#45;&gt;16910846413449957553 -->\r\n",
       "<g id=\"edge35\" class=\"edge\"><title>conv_pad_5/Pad&#45;&gt;16910846413449957553</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2904.82C104.5,-2894.19 104.5,-2880.31 104.5,-2868.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2868.15 104.5,-2858.15 101,-2868.15 108,-2868.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2879\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x30x30x256</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_6/Pad -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>conv_pad_6/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-2692 77.5,-2692 77.5,-2656 131.5,-2656 131.5,-2692\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-2671\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 14638143127111540757 -->\r\n",
       "<g id=\"node44\" class=\"node\"><title>14638143127111540757</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"209,-2609 0,-2609 0,-2573 209,-2573 209,-2609\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-2588\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3/s2 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_6/Pad&#45;&gt;14638143127111540757 -->\r\n",
       "<g id=\"edge37\" class=\"edge\"><title>conv_pad_6/Pad&#45;&gt;14638143127111540757</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2655.82C104.5,-2645.19 104.5,-2631.31 104.5,-2619.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2619.15 104.5,-2609.15 101,-2619.15 108,-2619.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2630\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x30x30x256</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_7/Pad -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>conv_pad_7/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-2443 77.5,-2443 77.5,-2407 131.5,-2407 131.5,-2443\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-2422\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 10174562932283943651 -->\r\n",
       "<g id=\"node45\" class=\"node\"><title>10174562932283943651</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-2360 7,-2360 7,-2324 202,-2324 202,-2360\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-2339\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_7/Pad&#45;&gt;10174562932283943651 -->\r\n",
       "<g id=\"edge39\" class=\"edge\"><title>conv_pad_7/Pad&#45;&gt;10174562932283943651</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2406.82C104.5,-2396.19 104.5,-2382.31 104.5,-2370.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2370.15 104.5,-2360.15 101,-2370.15 108,-2370.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2381\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x16x16x512</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_8/Pad -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>conv_pad_8/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-2194 77.5,-2194 77.5,-2158 131.5,-2158 131.5,-2194\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-2173\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 4130560916246705041 -->\r\n",
       "<g id=\"node46\" class=\"node\"><title>4130560916246705041</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-2111 7,-2111 7,-2075 202,-2075 202,-2111\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-2090\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_8/Pad&#45;&gt;4130560916246705041 -->\r\n",
       "<g id=\"edge41\" class=\"edge\"><title>conv_pad_8/Pad&#45;&gt;4130560916246705041</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2157.82C104.5,-2147.19 104.5,-2133.31 104.5,-2121.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2121.15 104.5,-2111.15 101,-2121.15 108,-2121.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2132\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x16x16x512</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_9/Pad -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>conv_pad_9/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-1945 77.5,-1945 77.5,-1909 131.5,-1909 131.5,-1945\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-1924\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 12919788106850998579 -->\r\n",
       "<g id=\"node47\" class=\"node\"><title>12919788106850998579</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-1862 7,-1862 7,-1826 202,-1826 202,-1862\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-1841\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_9/Pad&#45;&gt;12919788106850998579 -->\r\n",
       "<g id=\"edge43\" class=\"edge\"><title>conv_pad_9/Pad&#45;&gt;12919788106850998579</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1908.82C104.5,-1898.19 104.5,-1884.31 104.5,-1872.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1872.15 104.5,-1862.15 101,-1872.15 108,-1872.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1883\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x16x16x512</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_10/Pad -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>conv_pad_10/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-1696 77.5,-1696 77.5,-1660 131.5,-1660 131.5,-1696\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-1675\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 12980013121193741169 -->\r\n",
       "<g id=\"node48\" class=\"node\"><title>12980013121193741169</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-1613 7,-1613 7,-1577 202,-1577 202,-1613\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-1592\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_10/Pad&#45;&gt;12980013121193741169 -->\r\n",
       "<g id=\"edge45\" class=\"edge\"><title>conv_pad_10/Pad&#45;&gt;12980013121193741169</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1659.82C104.5,-1649.19 104.5,-1635.31 104.5,-1623.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1623.15 104.5,-1613.15 101,-1623.15 108,-1623.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1634\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x16x16x512</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_11/Pad -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>conv_pad_11/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-1447 77.5,-1447 77.5,-1411 131.5,-1411 131.5,-1447\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-1426\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 12730706752002349368 -->\r\n",
       "<g id=\"node49\" class=\"node\"><title>12730706752002349368</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-1364 7,-1364 7,-1328 202,-1328 202,-1364\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-1343\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_11/Pad&#45;&gt;12730706752002349368 -->\r\n",
       "<g id=\"edge47\" class=\"edge\"><title>conv_pad_11/Pad&#45;&gt;12730706752002349368</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1410.82C104.5,-1400.19 104.5,-1386.31 104.5,-1374.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1374.15 104.5,-1364.15 101,-1374.15 108,-1374.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1385\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x16x16x512</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_12/Pad -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>conv_pad_12/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-1198 77.5,-1198 77.5,-1162 131.5,-1162 131.5,-1198\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-1177\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 14011040362088291917 -->\r\n",
       "<g id=\"node50\" class=\"node\"><title>14011040362088291917</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"209,-1115 0,-1115 0,-1079 209,-1079 209,-1115\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-1094\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3/s2 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_12/Pad&#45;&gt;14011040362088291917 -->\r\n",
       "<g id=\"edge49\" class=\"edge\"><title>conv_pad_12/Pad&#45;&gt;14011040362088291917</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1161.82C104.5,-1151.19 104.5,-1137.31 104.5,-1125.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1125.15 104.5,-1115.15 101,-1125.15 108,-1125.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1136\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x16x16x512</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_13/Pad -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>conv_pad_13/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-949 77.5,-949 77.5,-913 131.5,-913 131.5,-949\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-928\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- 1695088444838233986 -->\r\n",
       "<g id=\"node51\" class=\"node\"><title>1695088444838233986</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"202,-866 7,-866 7,-830 202,-830 202,-866\"/>\r\n",
       "<text text-anchor=\"start\" x=\"15.5\" y=\"-845\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">SeparableConv3x3 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- conv_pad_13/Pad&#45;&gt;1695088444838233986 -->\r\n",
       "<g id=\"edge51\" class=\"edge\"><title>conv_pad_13/Pad&#45;&gt;1695088444838233986</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-912.822C104.5,-902.19 104.5,-888.306 104.5,-876.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-876.153 104.5,-866.153 101,-876.153 108,-876.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"129.5\" y=\"-887\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x9x9x1024</text>\r\n",
       "</g>\r\n",
       "<!-- global_average_pooling2d/Mean -->\r\n",
       "<g id=\"node16\" class=\"node\"><title>global_average_pooling2d/Mean</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-700 77.5,-700 77.5,-664 131.5,-664 131.5,-700\"/>\r\n",
       "<text text-anchor=\"start\" x=\"92.5\" y=\"-679\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Mean</text>\r\n",
       "</g>\r\n",
       "<!-- reshape_1/Reshape -->\r\n",
       "<g id=\"node17\" class=\"node\"><title>reshape_1/Reshape</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-617 77.5,-617 77.5,-581 131.5,-581 131.5,-617\"/>\r\n",
       "<text text-anchor=\"start\" x=\"86.5\" y=\"-596\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Reshape</text>\r\n",
       "</g>\r\n",
       "<!-- global_average_pooling2d/Mean&#45;&gt;reshape_1/Reshape -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>global_average_pooling2d/Mean&#45;&gt;reshape_1/Reshape</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-663.822C104.5,-653.19 104.5,-639.306 104.5,-627.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-627.153 104.5,-617.153 101,-627.153 108,-627.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"120\" y=\"-638\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1024</text>\r\n",
       "</g>\r\n",
       "<!-- conv_preds/Conv2D -->\r\n",
       "<g id=\"node18\" class=\"node\"><title>conv_preds/Conv2D</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"131.5,-534 77.5,-534 77.5,-498 131.5,-498 131.5,-534\"/>\r\n",
       "<text text-anchor=\"start\" x=\"86.5\" y=\"-513\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1</text>\r\n",
       "</g>\r\n",
       "<!-- reshape_1/Reshape&#45;&gt;conv_preds/Conv2D -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>reshape_1/Reshape&#45;&gt;conv_preds/Conv2D</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-580.822C104.5,-570.19 104.5,-556.306 104.5,-544.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-544.153 104.5,-534.153 101,-544.153 108,-544.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"129.5\" y=\"-555\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1024</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/Max -->\r\n",
       "<g id=\"node19\" class=\"node\"><title>act_softmax/Max</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"100.5,-451 46.5,-451 46.5,-415 100.5,-415 100.5,-451\"/>\r\n",
       "<text text-anchor=\"start\" x=\"64.5\" y=\"-430\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Max</text>\r\n",
       "</g>\r\n",
       "<!-- conv_preds/Conv2D&#45;&gt;act_softmax/Max -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>conv_preds/Conv2D&#45;&gt;act_softmax/Max</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M84.9192,-497.831C80.2856,-492.619 75.975,-486.527 73.5,-480 71.287,-474.164 70.4253,-467.604 70.296,-461.306\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"73.8002,-461.247 70.6606,-451.128 66.8047,-460.996 73.8002,-461.247\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"98.5\" y=\"-472\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1000</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/sub -->\r\n",
       "<g id=\"node20\" class=\"node\"><title>act_softmax/sub</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"136.5,-368 82.5,-368 82.5,-332 136.5,-332 136.5,-368\"/>\r\n",
       "<text text-anchor=\"start\" x=\"101.5\" y=\"-347\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Sub</text>\r\n",
       "</g>\r\n",
       "<!-- conv_preds/Conv2D&#45;&gt;act_softmax/sub -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>conv_preds/Conv2D&#45;&gt;act_softmax/sub</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M115.975,-497.902C119.04,-492.419 121.934,-486.165 123.5,-480 133.782,-439.507 131.4,-427.024 123.5,-386 122.973,-383.263 122.234,-380.467 121.367,-377.709\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"124.555,-376.235 117.826,-368.052 117.983,-378.645 124.555,-376.235\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"154.5\" y=\"-430.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1000</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/Max&#45;&gt;act_softmax/sub -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>act_softmax/Max&#45;&gt;act_softmax/sub</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M78.6917,-414.666C81.5202,-405.92 85.2984,-395.236 89.5,-386 90.8621,-383.006 92.3981,-379.932 93.9984,-376.907\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"97.086,-378.556 98.882,-368.115 90.9666,-375.157 97.086,-378.556\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"106.5\" y=\"-389\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/Exp -->\r\n",
       "<g id=\"node21\" class=\"node\"><title>act_softmax/Exp</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"136.5,-285 82.5,-285 82.5,-249 136.5,-249 136.5,-285\"/>\r\n",
       "<text text-anchor=\"start\" x=\"101.5\" y=\"-264\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Exp</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/sub&#45;&gt;act_softmax/Exp -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>act_softmax/sub&#45;&gt;act_softmax/Exp</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M109.5,-331.822C109.5,-321.19 109.5,-307.306 109.5,-295.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"113,-295.153 109.5,-285.153 106,-295.153 113,-295.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"134.5\" y=\"-306\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1000</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/Sum -->\r\n",
       "<g id=\"node22\" class=\"node\"><title>act_softmax/Sum</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"105.5,-202 51.5,-202 51.5,-166 105.5,-166 105.5,-202\"/>\r\n",
       "<text text-anchor=\"start\" x=\"68.5\" y=\"-181\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Sum</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/Exp&#45;&gt;act_softmax/Sum -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>act_softmax/Exp&#45;&gt;act_softmax/Sum</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M89.9192,-248.831C85.2856,-243.619 80.975,-237.527 78.5,-231 76.287,-225.164 75.4253,-218.604 75.296,-212.306\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"78.8002,-212.247 75.6606,-202.128 71.8047,-211.996 78.8002,-212.247\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"103.5\" y=\"-223\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1000</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/truediv -->\r\n",
       "<g id=\"node23\" class=\"node\"><title>act_softmax/truediv</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"141.5,-119 87.5,-119 87.5,-83 141.5,-83 141.5,-119\"/>\r\n",
       "<text text-anchor=\"start\" x=\"98.5\" y=\"-98\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">RealDiv</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/Exp&#45;&gt;act_softmax/truediv -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>act_softmax/Exp&#45;&gt;act_softmax/truediv</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M120.975,-248.902C124.04,-243.419 126.934,-237.165 128.5,-231 138.782,-190.507 136.4,-178.024 128.5,-137 127.973,-134.263 127.234,-131.467 126.367,-128.709\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"129.555,-127.235 122.826,-119.052 122.983,-129.645 129.555,-127.235\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"159.5\" y=\"-181.5\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1000</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/Sum&#45;&gt;act_softmax/truediv -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>act_softmax/Sum&#45;&gt;act_softmax/truediv</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M83.6917,-165.666C86.5202,-156.92 90.2984,-146.236 94.5,-137 95.8621,-134.006 97.3981,-130.932 98.9984,-127.907\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"102.086,-129.556 103.882,-119.115 95.9666,-126.157 102.086,-129.556\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"111.5\" y=\"-140\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1</text>\r\n",
       "</g>\r\n",
       "<!-- reshape_2/Reshape -->\r\n",
       "<g id=\"node24\" class=\"node\"><title>reshape_2/Reshape</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"141.5,-36 87.5,-36 87.5,-0 141.5,-0 141.5,-36\"/>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Reshape</text>\r\n",
       "</g>\r\n",
       "<!-- act_softmax/truediv&#45;&gt;reshape_2/Reshape -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>act_softmax/truediv&#45;&gt;reshape_2/Reshape</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M114.5,-82.822C114.5,-72.1903 114.5,-58.306 114.5,-46.2035\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"118,-46.1532 114.5,-36.1533 111,-46.1533 118,-46.1532\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"139.5\" y=\"-57\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1x1x1000</text>\r\n",
       "</g>\r\n",
       "<!-- 12149989648873824835&#45;&gt;conv_pad_1/Pad -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>12149989648873824835&#45;&gt;conv_pad_1/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3983.82C104.5,-3973.19 104.5,-3959.31 104.5,-3947.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3947.15 104.5,-3937.15 101,-3947.15 108,-3947.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"135\" y=\"-3958\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x112x112x32</text>\r\n",
       "</g>\r\n",
       "<!-- 9550784534775394061 -->\r\n",
       "<g id=\"node26\" class=\"node\"><title>9550784534775394061</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-3771 28.5,-3771 28.5,-3735 180.5,-3735 180.5,-3771\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-3750\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 9550784534775394061&#45;&gt;conv_pad_2/Pad -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>9550784534775394061&#45;&gt;conv_pad_2/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3734.82C104.5,-3724.19 104.5,-3710.31 104.5,-3698.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3698.15 104.5,-3688.15 101,-3698.15 108,-3698.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"135\" y=\"-3709\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x112x112x64</text>\r\n",
       "</g>\r\n",
       "<!-- 10840438013305070729 -->\r\n",
       "<g id=\"node27\" class=\"node\"><title>10840438013305070729</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-3522 28.5,-3522 28.5,-3486 180.5,-3486 180.5,-3522\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-3501\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 10840438013305070729&#45;&gt;conv_pad_3/Pad -->\r\n",
       "<g id=\"edge15\" class=\"edge\"><title>10840438013305070729&#45;&gt;conv_pad_3/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3485.82C104.5,-3475.19 104.5,-3461.31 104.5,-3449.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3449.15 104.5,-3439.15 101,-3449.15 108,-3449.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-3460\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x56x56x128</text>\r\n",
       "</g>\r\n",
       "<!-- 7825327471840062353 -->\r\n",
       "<g id=\"node28\" class=\"node\"><title>7825327471840062353</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-3273 28.5,-3273 28.5,-3237 180.5,-3237 180.5,-3273\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-3252\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 7825327471840062353&#45;&gt;conv_pad_4/Pad -->\r\n",
       "<g id=\"edge16\" class=\"edge\"><title>7825327471840062353&#45;&gt;conv_pad_4/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3236.82C104.5,-3226.19 104.5,-3212.31 104.5,-3200.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3200.15 104.5,-3190.15 101,-3200.15 108,-3200.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-3211\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x56x56x128</text>\r\n",
       "</g>\r\n",
       "<!-- 14391562900260021978 -->\r\n",
       "<g id=\"node29\" class=\"node\"><title>14391562900260021978</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-3024 28.5,-3024 28.5,-2988 180.5,-2988 180.5,-3024\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-3003\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 14391562900260021978&#45;&gt;conv_pad_5/Pad -->\r\n",
       "<g id=\"edge17\" class=\"edge\"><title>14391562900260021978&#45;&gt;conv_pad_5/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2987.82C104.5,-2977.19 104.5,-2963.31 104.5,-2951.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2951.15 104.5,-2941.15 101,-2951.15 108,-2951.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2962\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x256</text>\r\n",
       "</g>\r\n",
       "<!-- 9574202366971183990 -->\r\n",
       "<g id=\"node30\" class=\"node\"><title>9574202366971183990</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-2775 28.5,-2775 28.5,-2739 180.5,-2739 180.5,-2775\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-2754\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 9574202366971183990&#45;&gt;conv_pad_6/Pad -->\r\n",
       "<g id=\"edge18\" class=\"edge\"><title>9574202366971183990&#45;&gt;conv_pad_6/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2738.82C104.5,-2728.19 104.5,-2714.31 104.5,-2702.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2702.15 104.5,-2692.15 101,-2702.15 108,-2702.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2713\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x256</text>\r\n",
       "</g>\r\n",
       "<!-- 5219046486062832445 -->\r\n",
       "<g id=\"node31\" class=\"node\"><title>5219046486062832445</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-2526 28.5,-2526 28.5,-2490 180.5,-2490 180.5,-2526\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-2505\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 5219046486062832445&#45;&gt;conv_pad_7/Pad -->\r\n",
       "<g id=\"edge19\" class=\"edge\"><title>5219046486062832445&#45;&gt;conv_pad_7/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2489.82C104.5,-2479.19 104.5,-2465.31 104.5,-2453.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2453.15 104.5,-2443.15 101,-2453.15 108,-2453.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2464\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 13656417550049131995 -->\r\n",
       "<g id=\"node32\" class=\"node\"><title>13656417550049131995</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-2277 28.5,-2277 28.5,-2241 180.5,-2241 180.5,-2277\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-2256\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 13656417550049131995&#45;&gt;conv_pad_8/Pad -->\r\n",
       "<g id=\"edge20\" class=\"edge\"><title>13656417550049131995&#45;&gt;conv_pad_8/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2240.82C104.5,-2230.19 104.5,-2216.31 104.5,-2204.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2204.15 104.5,-2194.15 101,-2204.15 108,-2204.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2215\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 3395995287349026876 -->\r\n",
       "<g id=\"node33\" class=\"node\"><title>3395995287349026876</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-2028 28.5,-2028 28.5,-1992 180.5,-1992 180.5,-2028\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-2007\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 3395995287349026876&#45;&gt;conv_pad_9/Pad -->\r\n",
       "<g id=\"edge21\" class=\"edge\"><title>3395995287349026876&#45;&gt;conv_pad_9/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1991.82C104.5,-1981.19 104.5,-1967.31 104.5,-1955.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1955.15 104.5,-1945.15 101,-1955.15 108,-1955.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1966\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 14125565753319098839 -->\r\n",
       "<g id=\"node34\" class=\"node\"><title>14125565753319098839</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-1779 28.5,-1779 28.5,-1743 180.5,-1743 180.5,-1779\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-1758\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 14125565753319098839&#45;&gt;conv_pad_10/Pad -->\r\n",
       "<g id=\"edge22\" class=\"edge\"><title>14125565753319098839&#45;&gt;conv_pad_10/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1742.82C104.5,-1732.19 104.5,-1718.31 104.5,-1706.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1706.15 104.5,-1696.15 101,-1706.15 108,-1706.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1717\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 6843489362158297031 -->\r\n",
       "<g id=\"node35\" class=\"node\"><title>6843489362158297031</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-1530 28.5,-1530 28.5,-1494 180.5,-1494 180.5,-1530\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-1509\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 6843489362158297031&#45;&gt;conv_pad_11/Pad -->\r\n",
       "<g id=\"edge23\" class=\"edge\"><title>6843489362158297031&#45;&gt;conv_pad_11/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1493.82C104.5,-1483.19 104.5,-1469.31 104.5,-1457.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1457.15 104.5,-1447.15 101,-1457.15 108,-1457.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1468\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 16767394360978906089 -->\r\n",
       "<g id=\"node36\" class=\"node\"><title>16767394360978906089</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-1281 28.5,-1281 28.5,-1245 180.5,-1245 180.5,-1281\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-1260\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 16767394360978906089&#45;&gt;conv_pad_12/Pad -->\r\n",
       "<g id=\"edge24\" class=\"edge\"><title>16767394360978906089&#45;&gt;conv_pad_12/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1244.82C104.5,-1234.19 104.5,-1220.31 104.5,-1208.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1208.15 104.5,-1198.15 101,-1208.15 108,-1208.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1219\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 6006369320514856331 -->\r\n",
       "<g id=\"node37\" class=\"node\"><title>6006369320514856331</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-1032 28.5,-1032 28.5,-996 180.5,-996 180.5,-1032\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-1011\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 6006369320514856331&#45;&gt;conv_pad_13/Pad -->\r\n",
       "<g id=\"edge25\" class=\"edge\"><title>6006369320514856331&#45;&gt;conv_pad_13/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-995.822C104.5,-985.19 104.5,-971.306 104.5,-959.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-959.153 104.5,-949.153 101,-959.153 108,-959.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"129.5\" y=\"-970\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x1024</text>\r\n",
       "</g>\r\n",
       "<!-- 14974246297603517792 -->\r\n",
       "<g id=\"node38\" class=\"node\"><title>14974246297603517792</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"180.5,-783 28.5,-783 28.5,-747 180.5,-747 180.5,-783\"/>\r\n",
       "<text text-anchor=\"start\" x=\"36.5\" y=\"-762\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv1x1 &gt; BatchNorm &gt; ReLU6</text>\r\n",
       "</g>\r\n",
       "<!-- 14974246297603517792&#45;&gt;global_average_pooling2d/Mean -->\r\n",
       "<g id=\"edge26\" class=\"edge\"><title>14974246297603517792&#45;&gt;global_average_pooling2d/Mean</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-746.822C104.5,-736.19 104.5,-722.306 104.5,-710.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-710.153 104.5,-700.153 101,-710.153 108,-710.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"129.5\" y=\"-721\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x1024</text>\r\n",
       "</g>\r\n",
       "<!-- 1476947437174655940&#45;&gt;9550784534775394061 -->\r\n",
       "<g id=\"edge28\" class=\"edge\"><title>1476947437174655940&#45;&gt;9550784534775394061</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3817.82C104.5,-3807.19 104.5,-3793.31 104.5,-3781.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3781.15 104.5,-3771.15 101,-3781.15 108,-3781.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"135\" y=\"-3792\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x112x112x32</text>\r\n",
       "</g>\r\n",
       "<!-- 11222317214380384061&#45;&gt;10840438013305070729 -->\r\n",
       "<g id=\"edge30\" class=\"edge\"><title>11222317214380384061&#45;&gt;10840438013305070729</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3568.82C104.5,-3558.19 104.5,-3544.31 104.5,-3532.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3532.15 104.5,-3522.15 101,-3532.15 108,-3532.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"129.5\" y=\"-3543\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x56x56x64</text>\r\n",
       "</g>\r\n",
       "<!-- 8430071148413196380&#45;&gt;7825327471840062353 -->\r\n",
       "<g id=\"edge32\" class=\"edge\"><title>8430071148413196380&#45;&gt;7825327471840062353</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3319.82C104.5,-3309.19 104.5,-3295.31 104.5,-3283.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3283.15 104.5,-3273.15 101,-3283.15 108,-3283.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-3294\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x56x56x128</text>\r\n",
       "</g>\r\n",
       "<!-- 2224110879536963875&#45;&gt;14391562900260021978 -->\r\n",
       "<g id=\"edge34\" class=\"edge\"><title>2224110879536963875&#45;&gt;14391562900260021978</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-3070.82C104.5,-3060.19 104.5,-3046.31 104.5,-3034.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-3034.15 104.5,-3024.15 101,-3034.15 108,-3034.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-3045\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x128</text>\r\n",
       "</g>\r\n",
       "<!-- 16910846413449957553&#45;&gt;9574202366971183990 -->\r\n",
       "<g id=\"edge36\" class=\"edge\"><title>16910846413449957553&#45;&gt;9574202366971183990</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2821.82C104.5,-2811.19 104.5,-2797.31 104.5,-2785.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2785.15 104.5,-2775.15 101,-2785.15 108,-2785.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2796\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x256</text>\r\n",
       "</g>\r\n",
       "<!-- 14638143127111540757&#45;&gt;5219046486062832445 -->\r\n",
       "<g id=\"edge38\" class=\"edge\"><title>14638143127111540757&#45;&gt;5219046486062832445</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2572.82C104.5,-2562.19 104.5,-2548.31 104.5,-2536.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2536.15 104.5,-2526.15 101,-2536.15 108,-2536.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2547\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x256</text>\r\n",
       "</g>\r\n",
       "<!-- 10174562932283943651&#45;&gt;13656417550049131995 -->\r\n",
       "<g id=\"edge40\" class=\"edge\"><title>10174562932283943651&#45;&gt;13656417550049131995</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2323.82C104.5,-2313.19 104.5,-2299.31 104.5,-2287.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2287.15 104.5,-2277.15 101,-2287.15 108,-2287.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2298\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 4130560916246705041&#45;&gt;3395995287349026876 -->\r\n",
       "<g id=\"edge42\" class=\"edge\"><title>4130560916246705041&#45;&gt;3395995287349026876</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-2074.82C104.5,-2064.19 104.5,-2050.31 104.5,-2038.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-2038.15 104.5,-2028.15 101,-2038.15 108,-2038.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-2049\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 12919788106850998579&#45;&gt;14125565753319098839 -->\r\n",
       "<g id=\"edge44\" class=\"edge\"><title>12919788106850998579&#45;&gt;14125565753319098839</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1825.82C104.5,-1815.19 104.5,-1801.31 104.5,-1789.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1789.15 104.5,-1779.15 101,-1789.15 108,-1789.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1800\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 12980013121193741169&#45;&gt;6843489362158297031 -->\r\n",
       "<g id=\"edge46\" class=\"edge\"><title>12980013121193741169&#45;&gt;6843489362158297031</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1576.82C104.5,-1566.19 104.5,-1552.31 104.5,-1540.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1540.15 104.5,-1530.15 101,-1540.15 108,-1540.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1551\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 12730706752002349368&#45;&gt;16767394360978906089 -->\r\n",
       "<g id=\"edge48\" class=\"edge\"><title>12730706752002349368&#45;&gt;16767394360978906089</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1327.82C104.5,-1317.19 104.5,-1303.31 104.5,-1291.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1291.15 104.5,-1281.15 101,-1291.15 108,-1291.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"132\" y=\"-1302\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 14011040362088291917&#45;&gt;6006369320514856331 -->\r\n",
       "<g id=\"edge50\" class=\"edge\"><title>14011040362088291917&#45;&gt;6006369320514856331</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-1078.82C104.5,-1068.19 104.5,-1054.31 104.5,-1042.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-1042.15 104.5,-1032.15 101,-1042.15 108,-1042.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"127\" y=\"-1053\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x512</text>\r\n",
       "</g>\r\n",
       "<!-- 1695088444838233986&#45;&gt;14974246297603517792 -->\r\n",
       "<g id=\"edge52\" class=\"edge\"><title>1695088444838233986&#45;&gt;14974246297603517792</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M104.5,-829.822C104.5,-819.19 104.5,-805.306 104.5,-793.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"108,-793.153 104.5,-783.153 101,-793.153 108,-793.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"129.5\" y=\"-804\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x1024</text>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<hiddenlayer.graph.Graph at 0x174207f2cc0>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Build the model\n",
    "model = MobileNet(input_shape=(224, 224, 3))\n",
    "\n",
    "# Define custom transforms to group nodes into modules\n",
    "transforms = [\n",
    "    # Build basic folds first\n",
    "    # Note that the activation function used by MobileNet is ReLU6\n",
    "    # The authors of the MobileNet paper found it more robust than regular ReLU in fixed-point inference\n",
    "    ht.Fold(\"Relu > Minimum > Maximum\", \"Relu\", \"ReLU6\"),\n",
    "    ht.Fold(\"Conv > BatchNorm\", \"ConvBn\"),\n",
    "    ht.Fold(\"ConvBn > Relu\", \"ConvBnRelu\"),\n",
    "    ht.Fold(\"SeparableConv > BatchNorm\", \"SeparableConvBn\"),\n",
    "    ht.Fold(\"SeparableConvBn > Relu\", \"SeparableConvBnRelu\"),\n",
    "    # You could further simplify the graph by folding nodes into \"depthwise separable” convolution blocks\n",
    "    # To do so, simply uncomment the line below:\n",
    "    # ht.Fold(\"SeparableConvBnRelu > ConvBnRelu > Pad\", \"Depthwise Separable Conv Block\", \"Depthwise Separable Conv Block\"),\n",
    "    ht.FoldDuplicates(),\n",
    "]\n",
    "\n",
    "# Build model graph view and display it\n",
    "hl_graph = hl.build_graph(K.get_session().graph, transforms=transforms)\n",
    "hl_graph"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## DenseNet121 with 4 DenseNet-B Blocks (x6, x12, x24, x16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create a new graph and set the learning phase to inference\n",
    "K.clear_session()\n",
    "K.set_learning_phase(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\r\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\r\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\r\n",
       " -->\r\n",
       "<!-- Title: %3 Pages: 1 -->\r\n",
       "<svg width=\"287pt\" height=\"1800pt\"\r\n",
       " viewBox=\"0.00 0.00 287.00 1800.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 1764)\">\r\n",
       "<title>%3</title>\r\n",
       "<polygon fill=\"#ffffff\" stroke=\"none\" points=\"-72,36 -72,-1764 215,-1764 215,36 -72,36\"/>\r\n",
       "<!-- input_1 -->\r\n",
       "<g id=\"node1\" class=\"node\"><title>input_1</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"104.5,-1728 38.5,-1728 38.5,-1692 104.5,-1692 104.5,-1728\"/>\r\n",
       "<text text-anchor=\"start\" x=\"46.5\" y=\"-1707\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Placeholder</text>\r\n",
       "</g>\r\n",
       "<!-- zero_padding2d/Pad -->\r\n",
       "<g id=\"node2\" class=\"node\"><title>zero_padding2d/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"98.5,-1645 44.5,-1645 44.5,-1609 98.5,-1609 98.5,-1645\"/>\r\n",
       "<text text-anchor=\"start\" x=\"63.5\" y=\"-1624\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- input_1&#45;&gt;zero_padding2d/Pad -->\r\n",
       "<g id=\"edge1\" class=\"edge\"><title>input_1&#45;&gt;zero_padding2d/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1691.82C71.5,-1681.19 71.5,-1667.31 71.5,-1655.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-1655.15 71.5,-1645.15 68.0001,-1655.15 75.0001,-1655.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-1666\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x224x224x3</text>\r\n",
       "</g>\r\n",
       "<!-- conv1/conv/Conv2D -->\r\n",
       "<g id=\"node3\" class=\"node\"><title>conv1/conv/Conv2D</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"104.5,-1562 38.5,-1562 38.5,-1526 104.5,-1526 104.5,-1562\"/>\r\n",
       "<text text-anchor=\"start\" x=\"46.5\" y=\"-1541\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Conv7x7/s2</text>\r\n",
       "</g>\r\n",
       "<!-- zero_padding2d/Pad&#45;&gt;conv1/conv/Conv2D -->\r\n",
       "<g id=\"edge2\" class=\"edge\"><title>zero_padding2d/Pad&#45;&gt;conv1/conv/Conv2D</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1608.82C71.5,-1598.19 71.5,-1584.31 71.5,-1572.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-1572.15 71.5,-1562.15 68.0001,-1572.15 75.0001,-1572.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-1583\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x230x230x3</text>\r\n",
       "</g>\r\n",
       "<!-- conv1/bn/FusedBatchNorm -->\r\n",
       "<g id=\"node4\" class=\"node\"><title>conv1/bn/FusedBatchNorm</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"103,-1479 40,-1479 40,-1443 103,-1443 103,-1479\"/>\r\n",
       "<text text-anchor=\"start\" x=\"48.5\" y=\"-1458\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- conv1/conv/Conv2D&#45;&gt;conv1/bn/FusedBatchNorm -->\r\n",
       "<g id=\"edge3\" class=\"edge\"><title>conv1/conv/Conv2D&#45;&gt;conv1/bn/FusedBatchNorm</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1525.82C71.5,-1515.19 71.5,-1501.31 71.5,-1489.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-1489.15 71.5,-1479.15 68.0001,-1489.15 75.0001,-1489.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"102\" y=\"-1500\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x112x112x64</text>\r\n",
       "</g>\r\n",
       "<!-- conv1/relu/Relu -->\r\n",
       "<g id=\"node5\" class=\"node\"><title>conv1/relu/Relu</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"98.5,-1396 44.5,-1396 44.5,-1360 98.5,-1360 98.5,-1396\"/>\r\n",
       "<text text-anchor=\"start\" x=\"62.5\" y=\"-1375\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Relu</text>\r\n",
       "</g>\r\n",
       "<!-- conv1/bn/FusedBatchNorm&#45;&gt;conv1/relu/Relu -->\r\n",
       "<g id=\"edge4\" class=\"edge\"><title>conv1/bn/FusedBatchNorm&#45;&gt;conv1/relu/Relu</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1442.82C71.5,-1432.19 71.5,-1418.31 71.5,-1406.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-1406.15 71.5,-1396.15 68.0001,-1406.15 75.0001,-1406.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"102\" y=\"-1417\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x112x112x64</text>\r\n",
       "</g>\r\n",
       "<!-- zero_padding2d_1/Pad -->\r\n",
       "<g id=\"node6\" class=\"node\"><title>zero_padding2d_1/Pad</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"98.5,-1313 44.5,-1313 44.5,-1277 98.5,-1277 98.5,-1313\"/>\r\n",
       "<text text-anchor=\"start\" x=\"63.5\" y=\"-1292\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Pad</text>\r\n",
       "</g>\r\n",
       "<!-- conv1/relu/Relu&#45;&gt;zero_padding2d_1/Pad -->\r\n",
       "<g id=\"edge5\" class=\"edge\"><title>conv1/relu/Relu&#45;&gt;zero_padding2d_1/Pad</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1359.82C71.5,-1349.19 71.5,-1335.31 71.5,-1323.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-1323.15 71.5,-1313.15 68.0001,-1323.15 75.0001,-1323.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"102\" y=\"-1334\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x112x112x64</text>\r\n",
       "</g>\r\n",
       "<!-- pool1/MaxPool -->\r\n",
       "<g id=\"node7\" class=\"node\"><title>pool1/MaxPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"111.5,-1230 31.5,-1230 31.5,-1194 111.5,-1194 111.5,-1230\"/>\r\n",
       "<text text-anchor=\"start\" x=\"39.5\" y=\"-1209\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">MaxPool3x3/s2</text>\r\n",
       "</g>\r\n",
       "<!-- zero_padding2d_1/Pad&#45;&gt;pool1/MaxPool -->\r\n",
       "<g id=\"edge6\" class=\"edge\"><title>zero_padding2d_1/Pad&#45;&gt;pool1/MaxPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1276.82C71.5,-1266.19 71.5,-1252.31 71.5,-1240.2\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-1240.15 71.5,-1230.15 68.0001,-1240.15 75.0001,-1240.15\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"102\" y=\"-1251\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x114x114x64</text>\r\n",
       "</g>\r\n",
       "<!-- 13529228391036336580 -->\r\n",
       "<g id=\"node18\" class=\"node\"><title>13529228391036336580</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"110,-1147 33,-1147 33,-1103 110,-1103 110,-1147\"/>\r\n",
       "<text text-anchor=\"start\" x=\"41.5\" y=\"-1131\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Residual Block</text>\r\n",
       "<text text-anchor=\"start\" x=\"96.5\" y=\"-1110\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x6</text>\r\n",
       "</g>\r\n",
       "<!-- pool1/MaxPool&#45;&gt;13529228391036336580 -->\r\n",
       "<g id=\"edge13\" class=\"edge\"><title>pool1/MaxPool&#45;&gt;13529228391036336580</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1193.8C71.5,-1183.37 71.5,-1169.74 71.5,-1157.44\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-1157.09 71.5,-1147.09 68.0001,-1157.09 75.0001,-1157.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"96.5\" y=\"-1168\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x56x56x64</text>\r\n",
       "</g>\r\n",
       "<!-- pool2_pool/AvgPool -->\r\n",
       "<g id=\"node8\" class=\"node\"><title>pool2_pool/AvgPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"111,-973 32,-973 32,-937 111,-937 111,-973\"/>\r\n",
       "<text text-anchor=\"start\" x=\"40.5\" y=\"-952\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">AvgPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 6369800046382204283 -->\r\n",
       "<g id=\"node19\" class=\"node\"><title>6369800046382204283</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"110,-890 33,-890 33,-846 110,-846 110,-890\"/>\r\n",
       "<text text-anchor=\"start\" x=\"41.5\" y=\"-874\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Residual Block</text>\r\n",
       "<text text-anchor=\"start\" x=\"90.5\" y=\"-853\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x12</text>\r\n",
       "</g>\r\n",
       "<!-- pool2_pool/AvgPool&#45;&gt;6369800046382204283 -->\r\n",
       "<g id=\"edge15\" class=\"edge\"><title>pool2_pool/AvgPool&#45;&gt;6369800046382204283</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-936.799C71.5,-926.369 71.5,-912.742 71.5,-900.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-900.09 71.5,-890.09 68.0001,-900.09 75.0001,-900.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-911\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x128</text>\r\n",
       "</g>\r\n",
       "<!-- pool3_pool/AvgPool -->\r\n",
       "<g id=\"node9\" class=\"node\"><title>pool3_pool/AvgPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"111,-716 32,-716 32,-680 111,-680 111,-716\"/>\r\n",
       "<text text-anchor=\"start\" x=\"40.5\" y=\"-695\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">AvgPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 6681538025985023332 -->\r\n",
       "<g id=\"node21\" class=\"node\"><title>6681538025985023332</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"110,-633 33,-633 33,-589 110,-589 110,-633\"/>\r\n",
       "<text text-anchor=\"start\" x=\"41.5\" y=\"-617\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Residual Block</text>\r\n",
       "<text text-anchor=\"start\" x=\"90.5\" y=\"-596\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x24</text>\r\n",
       "</g>\r\n",
       "<!-- pool3_pool/AvgPool&#45;&gt;6681538025985023332 -->\r\n",
       "<g id=\"edge19\" class=\"edge\"><title>pool3_pool/AvgPool&#45;&gt;6681538025985023332</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-679.799C71.5,-669.369 71.5,-655.742 71.5,-643.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-643.09 71.5,-633.09 68.0001,-643.09 75.0001,-643.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-654\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x256</text>\r\n",
       "</g>\r\n",
       "<!-- pool4_pool/AvgPool -->\r\n",
       "<g id=\"node10\" class=\"node\"><title>pool4_pool/AvgPool</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"111,-459 32,-459 32,-423 111,-423 111,-459\"/>\r\n",
       "<text text-anchor=\"start\" x=\"40.5\" y=\"-438\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">AvgPool2x2/s2</text>\r\n",
       "</g>\r\n",
       "<!-- 16376491955449020304 -->\r\n",
       "<g id=\"node20\" class=\"node\"><title>16376491955449020304</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"110,-376 33,-376 33,-332 110,-332 110,-376\"/>\r\n",
       "<text text-anchor=\"start\" x=\"41.5\" y=\"-360\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Residual Block</text>\r\n",
       "<text text-anchor=\"start\" x=\"90.5\" y=\"-339\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">x16</text>\r\n",
       "</g>\r\n",
       "<!-- pool4_pool/AvgPool&#45;&gt;16376491955449020304 -->\r\n",
       "<g id=\"edge17\" class=\"edge\"><title>pool4_pool/AvgPool&#45;&gt;16376491955449020304</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-422.799C71.5,-412.369 71.5,-398.742 71.5,-386.443\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-386.09 71.5,-376.09 68.0001,-386.09 75.0001,-386.09\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"94\" y=\"-397\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x512</text>\r\n",
       "</g>\r\n",
       "<!-- bn/FusedBatchNorm -->\r\n",
       "<g id=\"node11\" class=\"node\"><title>bn/FusedBatchNorm</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"103,-285 40,-285 40,-249 103,-249 103,-285\"/>\r\n",
       "<text text-anchor=\"start\" x=\"48.5\" y=\"-264\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">BatchNorm</text>\r\n",
       "</g>\r\n",
       "<!-- avg_pool/Mean -->\r\n",
       "<g id=\"node12\" class=\"node\"><title>avg_pool/Mean</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"98.5,-202 44.5,-202 44.5,-166 98.5,-166 98.5,-202\"/>\r\n",
       "<text text-anchor=\"start\" x=\"59.5\" y=\"-181\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Mean</text>\r\n",
       "</g>\r\n",
       "<!-- bn/FusedBatchNorm&#45;&gt;avg_pool/Mean -->\r\n",
       "<g id=\"edge7\" class=\"edge\"><title>bn/FusedBatchNorm&#45;&gt;avg_pool/Mean</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-248.822C71.5,-238.19 71.5,-224.306 71.5,-212.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-212.153 71.5,-202.153 68.0001,-212.153 75.0001,-212.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"96.5\" y=\"-223\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x1024</text>\r\n",
       "</g>\r\n",
       "<!-- fc1000/MatMul -->\r\n",
       "<g id=\"node13\" class=\"node\"><title>fc1000/MatMul</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"98.5,-119 44.5,-119 44.5,-83 98.5,-83 98.5,-119\"/>\r\n",
       "<text text-anchor=\"start\" x=\"58.5\" y=\"-98\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Linear</text>\r\n",
       "</g>\r\n",
       "<!-- avg_pool/Mean&#45;&gt;fc1000/MatMul -->\r\n",
       "<g id=\"edge8\" class=\"edge\"><title>avg_pool/Mean&#45;&gt;fc1000/MatMul</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-165.822C71.5,-155.19 71.5,-141.306 71.5,-129.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-129.153 71.5,-119.153 68.0001,-129.153 75.0001,-129.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"87\" y=\"-140\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1024</text>\r\n",
       "</g>\r\n",
       "<!-- fc1000/Softmax -->\r\n",
       "<g id=\"node14\" class=\"node\"><title>fc1000/Softmax</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"98.5,-36 44.5,-36 44.5,-0 98.5,-0 98.5,-36\"/>\r\n",
       "<text text-anchor=\"start\" x=\"53.5\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Softmax</text>\r\n",
       "</g>\r\n",
       "<!-- fc1000/MatMul&#45;&gt;fc1000/Softmax -->\r\n",
       "<g id=\"edge9\" class=\"edge\"><title>fc1000/MatMul&#45;&gt;fc1000/Softmax</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-82.822C71.5,-72.1903 71.5,-58.306 71.5,-46.2035\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-46.1532 71.5,-36.1533 68.0001,-46.1533 75.0001,-46.1532\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"87\" y=\"-57\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x1000</text>\r\n",
       "</g>\r\n",
       "<!-- 11370519886697208145 -->\r\n",
       "<g id=\"node15\" class=\"node\"><title>11370519886697208145</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"143,-1056 0,-1056 0,-1020 143,-1020 143,-1056\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-1035\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">BatchNorm &gt; Relu &gt; Conv1x1</text>\r\n",
       "</g>\r\n",
       "<!-- 11370519886697208145&#45;&gt;pool2_pool/AvgPool -->\r\n",
       "<g id=\"edge10\" class=\"edge\"><title>11370519886697208145&#45;&gt;pool2_pool/AvgPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1019.82C71.5,-1009.19 71.5,-995.306 71.5,-983.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-983.153 71.5,-973.153 68.0001,-983.153 75.0001,-983.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-994\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x56x56x128</text>\r\n",
       "</g>\r\n",
       "<!-- 14769988216901348732 -->\r\n",
       "<g id=\"node16\" class=\"node\"><title>14769988216901348732</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"143,-799 0,-799 0,-763 143,-763 143,-799\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-778\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">BatchNorm &gt; Relu &gt; Conv1x1</text>\r\n",
       "</g>\r\n",
       "<!-- 14769988216901348732&#45;&gt;pool3_pool/AvgPool -->\r\n",
       "<g id=\"edge11\" class=\"edge\"><title>14769988216901348732&#45;&gt;pool3_pool/AvgPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-762.822C71.5,-752.19 71.5,-738.306 71.5,-726.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-726.153 71.5,-716.153 68.0001,-726.153 75.0001,-726.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-737\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x256</text>\r\n",
       "</g>\r\n",
       "<!-- 8668318680144634435 -->\r\n",
       "<g id=\"node17\" class=\"node\"><title>8668318680144634435</title>\r\n",
       "<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"143,-542 0,-542 0,-506 143,-506 143,-542\"/>\r\n",
       "<text text-anchor=\"start\" x=\"8.5\" y=\"-521\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">BatchNorm &gt; Relu &gt; Conv1x1</text>\r\n",
       "</g>\r\n",
       "<!-- 8668318680144634435&#45;&gt;pool4_pool/AvgPool -->\r\n",
       "<g id=\"edge12\" class=\"edge\"><title>8668318680144634435&#45;&gt;pool4_pool/AvgPool</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-505.822C71.5,-495.19 71.5,-481.306 71.5,-469.204\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-469.153 71.5,-459.153 68.0001,-469.153 75.0001,-469.153\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-480\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x512</text>\r\n",
       "</g>\r\n",
       "<!-- 13529228391036336580&#45;&gt;11370519886697208145 -->\r\n",
       "<g id=\"edge14\" class=\"edge\"><title>13529228391036336580&#45;&gt;11370519886697208145</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-1102.99C71.5,-1091.92 71.5,-1078.22 71.5,-1066.34\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-1066.06 71.5,-1056.06 68.0001,-1066.06 75.0001,-1066.06\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"96.5\" y=\"-1077\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x56x56x96</text>\r\n",
       "</g>\r\n",
       "<!-- 6369800046382204283&#45;&gt;14769988216901348732 -->\r\n",
       "<g id=\"edge16\" class=\"edge\"><title>6369800046382204283&#45;&gt;14769988216901348732</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-845.989C71.5,-834.923 71.5,-821.219 71.5,-809.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-809.062 71.5,-799.062 68.0001,-809.062 75.0001,-809.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-820\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x28x28x160</text>\r\n",
       "</g>\r\n",
       "<!-- 16376491955449020304&#45;&gt;bn/FusedBatchNorm -->\r\n",
       "<g id=\"edge18\" class=\"edge\"><title>16376491955449020304&#45;&gt;bn/FusedBatchNorm</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-331.989C71.5,-320.923 71.5,-307.219 71.5,-295.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-295.062 71.5,-285.062 68.0001,-295.062 75.0001,-295.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"94\" y=\"-306\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x7x7x544</text>\r\n",
       "</g>\r\n",
       "<!-- 6681538025985023332&#45;&gt;8668318680144634435 -->\r\n",
       "<g id=\"edge20\" class=\"edge\"><title>6681538025985023332&#45;&gt;8668318680144634435</title>\r\n",
       "<path fill=\"none\" stroke=\"#000000\" d=\"M71.5,-588.989C71.5,-577.923 71.5,-564.219 71.5,-552.336\"/>\r\n",
       "<polygon fill=\"#000000\" stroke=\"#000000\" points=\"75.0001,-552.062 71.5,-542.062 68.0001,-552.062 75.0001,-552.062\"/>\r\n",
       "<text text-anchor=\"middle\" x=\"99\" y=\"-563\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">?x14x14x288</text>\r\n",
       "</g>\r\n",
       "</g>\r\n",
       "</svg>\r\n"
      ],
      "text/plain": [
       "<hiddenlayer.graph.Graph at 0x1741ef56748>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Build the model\n",
    "model = DenseNet121(input_shape=(224, 224, 3))\n",
    "\n",
    "# Define custom transforms to group nodes into modules\n",
    "transforms = [\n",
    "    # Build basic folds first\n",
    "    ht.Fold(\"BatchNorm > Relu > Conv\", \"BnReluConv\"),\n",
    "    ht.Fold(\"BnReluConv > BnReluConv> Concat\", \"ResBlock\", \"Residual Block\"),\n",
    "    ht.FoldDuplicates(),\n",
    "]\n",
    "\n",
    "# Build model graph view and display it\n",
    "hl_graph = hl.build_graph(K.get_session().graph, transforms=transforms)\n",
    "hl_graph"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
